Escaping spaces in arguments to shell script
Derek Atkins
warlord at MIT.EDU
Wed Apr 26 13:02:44 EDT 2006
Hi,
Quoting Steven Erat <stevenerat at yahoo.com>:
> Would someone kindly suggest the solution to passing input parameters to a
> shell script where the arguments may contain spaces?
Put quotes around it...
> [auser at localhost ~]$ cat makeLink.sh
> #!/bin/sh
> echo First arg is: $1, Second arg is $2
> /bin/ln -s $1 $2
Change this to:
/bin/ln -s "$1" "$2"
Although that will probably have problems if you have embedded quotes
in your filenames.
-derek
--
Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
Member, MIT Student Information Processing Board (SIPB)
URL: http://web.mit.edu/warlord/ PP-ASEL-IA N1NWH
warlord at MIT.EDU PGP key available
More information about the Discuss
mailing list