Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Escaping spaces in arguments to shell script



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





BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org