Escaping spaces in arguments to shell script

Matej Cepl ceplm at seznam.cz
Wed Apr 26 23:18:35 EDT 2006


Matthew Gillen wrote:
> You're using a combination of quotes and escape ('\'), and therefore the
> escape is being used literally.
>> [auser at localhost ~]$ ./makeLink.sh foo 'some\ thing'

Moreover, read in bash(1) difference between doublequotes (") and single
quotes (') -- contrary to other languages (Python) they are not the same in
bash. Single quotes are much more literal, so '\ ' could mean really
<backslash><space>. On the other hand, if you use ' ', you don't have to
bother with escaping the space at all.

Matej

-- 
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
http://www.ceplovi.cz/matej/blog/, Jabber: ceplma at jabber.cz
23 Marion St. #3, (617) 876-1259, ICQ 132822213
 
I've just learned about his illness. Let's hope it's nothing
trivial.
      -- Irvin S. Cobb




More information about the Discuss mailing list