Page 1 of 1

Echoing double quotes

Posted: Tue Mar 15, 2005 7:00 am
by Neo
Ho do i get the echo command to echo double-quotes (""). I tried the command

Code: Select all

echo \042
but got \042 echoed in the CSH.
How is this done?

Re:Echoing double quotes

Posted: Tue Mar 15, 2005 7:13 am
by distantvoices
provided you use the gnu-unix echo, this works like this:

Code: Select all

echo " \"   \" "
you simply hide the quotes with a backslash from being parsed/interpreted by echo.

the dos/windows echo just outputs what you give it, so it is pretty ok to issue echo " " " " in the dos box.

Re:Echoing double quotes

Posted: Tue Mar 15, 2005 7:21 am
by Neo
That does not work in csh only i bash.

Re:Echoing double quotes

Posted: Tue Mar 15, 2005 7:40 am
by distantvoices
reliant unix echo with csh:

Code: Select all

echo ? " " " " ? 
this issues: " " " "

Re:Echoing double quotes

Posted: Thu Mar 17, 2005 12:25 am
by mystran

Code: Select all

<08:24:41|mystran@teemu:~>$ tcsh
teemu ~ > echo ' " foobar " '
 " foobar " 
In bash, either the above, or \" escaping works.

Re:Echoing double quotes

Posted: Thu Mar 17, 2005 6:21 am
by Neo
beyond infinity wrote: reliant unix echo with csh:

Code: Select all

echo ? " " " " ? 
this issues: " " " "

And if the text has single quotes in it too...?

Re:Echoing double quotes

Posted: Thu Mar 17, 2005 9:34 am
by Candy
What about telling echo to interpret them?

Code: Select all

echo -e "\042"

Re:Echoing double quotes

Posted: Fri Mar 18, 2005 5:52 am
by Neo
@candy: so it has to be in double quotes eh?
Thanks a lot anyway folks.

Re:Echoing double quotes

Posted: Fri Mar 18, 2005 7:12 am
by Candy
Neo wrote: @candy: so it has to be in double quotes eh?
Thanks a lot anyway folks.
No, you need the -e. Otherwise it plain prints it, this way it interprets the \-stuff.