Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling directories with spaces

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I am having a problem handling directories that contain spaces. I guess it is a matter of using quotes properly but I cannot seem to come up with the correct syntax. My first problem is passing such a directory to a script such that it is treated as a single argument rather then individual arguments. For example:
Code:
   myscript "/Volumes/USER1/Common/This is a directory"
Instead of $1 containing the entire string, it contains: '/Volumes/USER1/Common/This'. Can someone help me with the syntax for dealing with this? TIA.
 
Thanks. I figured it out. I messed up and tried to use the output from 'echo $1' instead of $1 directly. I guess the 'echo' stripped off the '"' and that was the problem. Sorry.
 
Why make life hard for yourself? Don't use spaces in the first place.

When one door closes another one bangs shut too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top