[comp.unix.shell] how to echo the '

xwang@gmuvax2.gmu.edu (Xiang-Min Wang) (03/20/91)

I saw the following msg sometimes before:

	OK, in csh, I want to have this string echo'd...     ^[=@'^[H8
	Problem being, I can't get the ' to be echo'd.
	(I am putting this command into a shell script.)
	If I use the command...

	echo '=@'H8'

	...it thinks the string to be echo'd ends at the second '
	If I use the command...

	echo '=@\'H8'

	...it sees the \ as a character, thus moving the the wrong
	cursor position (this is a terminal plotting command).

      /vv\   \        	      __Insight from Oregon...Scott P. Nichols
_____/    \   ~~~~~~~~~~~~~~~~                      (nichols@en.ecn.purdue.edu)

Could you try:

	echo =@\'H8

I am sure this command gives the string =@'H8 echoed (but I am not sure
that is you want).

the single quote ' and the backslash \ are the csh metacharacters.
their functions are escaping the other csh metacharacters. a character
immediately following the backslash \ is not interpreted by csh (so that
' is echoed in my example). characters between two single quotes are not
interpreted by csh either (so the \ seen as a character in your
example).

BTW, on my machine (ultrix 4.x), the ' has to be matched.

good luck.

xwang

dfoster@jarthur.Claremont.EDU (Derek R. Foster) (03/20/91)

Someone whose name seems to have gotten lost wrote:
>	OK, in csh, I want to have this string echo'd...     ^[=@'^[H8
>	Problem being, I can't get the ' to be echo'd.
>	(I am putting this command into a shell script.)
>	If I use the command...
>
>	echo '=@'H8'
>
>	...it thinks the string to be echo'd ends at the second '
>	If I use the command...
>	echo '=@\'H8'
>
>	...it sees the \ as a character
>

To echo a string like   abc'def
  use the format
  echo 'abc'\''def'

This is read as:
  a string, 'abc'
  an escaped quote character, \' which will not be interpreted like a
  normal quote character by the shell,
  another string, 'def'

In your case, this becomes:
  echo '=@'\''H8'

I hope this helps!

Derek Riippa Foster