Escaping spaces in arguments to shell script

Jeff Kinz jkinz at kinz.org
Wed Apr 26 20:22:38 EDT 2006


On Wed, Apr 26, 2006 at 09:56:23AM -0700, Steven Erat wrote:
> Would someone kindly suggest the solution to passing input parameters to a
> shell script where the arguments may contain spaces?  
> 
> Please refer to the example below.

This is all covered here :

How can I find and deal with file names containing newlines, spaces or both?
http://wooledge.org/mywiki/BashFaq#faq20 -- 

 20. How can I find and deal with files names containing newlines, spaces or both?
http://shelldorado.dyndns.org/wiki/index.php/BashFaq#faq20
 
> 
> Thank you,
> Steven Erat
> 
> 
> [auser at localhost ~]$ ls
> makeLink.sh
> [auser at localhost ~]$ cat makeLink.sh 
> #!/bin/sh
> echo First arg is: $1, Second arg is $2
> /bin/ln -s $1 $2 
> [auser at localhost ~]$ mkdir foo
> [auser at localhost ~]$ ./makeLink.sh foo foo\ bar
> First arg is: foo, Second arg is foo bar
> /bin/ln: when making multiple links, last argument must be a directory
> [auser at localhost ~]$ ln -s foo boo\ hoo
> [auser at localhost ~]$ ls -l
> total 20
> lrwxrwxrwx  1 auser auser    3 Apr 26 11:50 boo hoo -> foo
> drwxrwxr-x  2 auser auser 4096 Apr 26 11:49 foo
> -rwxr-xr-x  1 auser auser   68 Apr 26 11:44 makeLink.sh
> [auser at localhost ~]$ ./makeLink.sh foo 'some\ thing'
> First arg is: foo, Second arg is some\ thing
> /bin/ln: when making multiple links, last argument must be a directory
> 
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://olduvai.blu.org/mailman/listinfo/discuss
> 

-- 
Jeff Kinz, Emergent Research, Hudson, MA.
Speech Recognition Technology was used to create this e-mail




More information about the Discuss mailing list