I'm reading shell tutorial today from http://www.tutorialspoint.com/unix/unix-quoting-mechanisms.htm
In which it mentions:
If a single quote appears within a string to be output, you should not put the whole string within single quotes instead you whould preceed that using a backslash () as follows:
echo 'It\'s Shell Programming'
I tried this on my centos server, it doesn't work, a >
prompts out to hint me type more.
I was wondering, since two single quotes transform every special characters into normal characters, which include escape symbol \
, but exclude itself, the '
,
how should I represent a single single quote '
in a single-quoted phrase?
echo It\'s Shell Programming
orecho "It's Shell Programming"
? – cuonglm Mar 02 '15 at 08:49echo Wow, I'm going to have lots of $$$$$$ now
– Zen Mar 02 '15 at 08:51$
, too. Something likeecho Wow, I\'m going to have lots of \$\$\$\$\$\$ now
or justecho Wow, I\'m going to have lots of '$$$$$$' now
– cuonglm Mar 02 '15 at 08:53echo 'It'"'"'s Shell Programming'
. I just divide it as 3 strings, the first and the last surrounded by single quotes, but the middle one have a single quote surrounded by double quotes. – jcbermu Mar 02 '15 at 09:06