Echoing double quotes

Programming, for all ages and all languages.
Post Reply
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Echoing double quotes

Post 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?
Only Human
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Echoing double quotes

Post 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.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Echoing double quotes

Post by Neo »

That does not work in csh only i bash.
Only Human
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Echoing double quotes

Post by distantvoices »

reliant unix echo with csh:

Code: Select all

echo ? " " " " ? 
this issues: " " " "
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
mystran

Re:Echoing double quotes

Post by mystran »

Code: Select all

<08:24:41|mystran@teemu:~>$ tcsh
teemu ~ > echo ' " foobar " '
 " foobar " 
In bash, either the above, or \" escaping works.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Echoing double quotes

Post 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...?
Only Human
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Echoing double quotes

Post by Candy »

What about telling echo to interpret them?

Code: Select all

echo -e "\042"
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Echoing double quotes

Post by Neo »

@candy: so it has to be in double quotes eh?
Thanks a lot anyway folks.
Only Human
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Echoing double quotes

Post 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.
Post Reply