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!

Spaces in Directory Names 1

Status
Not open for further replies.

jmarkus

Technical User
Oct 15, 2002
124
CA
I am trying to execute a script which reads directory pathnames from a file and using them as options of a command. The problem is the pathnames contain spaces and the command interprets these spaces as separating multiple options instead of a single one.

Is there a "universal" way to substitute spaces for a character and have UNIX interpret them correctly?

Barring that, is there a way to do it in Solaris?

Thanks,
Jeff
 
I think the problem is no matter how you frame it ugpc will always interpret a space as the beginning of a new option. Is there a substitution that can be put in the listing of directory pathnames for the space?

For example, in HTML documents I've seen %20 used so that:

directory one

becomes

directory%20one

Of course %20 doesn't work, but is there something else?

Jeff
 
You may consider to play with with symbolic links:[tt]
i=0
while read dir
do
ln -s "$dir" dir.$$.$i
args=args" -pdir.$$.$i"
i=`expr 1 + $i`
done </path/to/listofdirs
ugpc $args myfile
rm dir.$$.*[/tt]

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Did you try using eval?

eval ugpc `sed -e 's!^!-p"!' -e 's!$!"!' "$dirfile"` $myfile
 
Thanks PHV, symbolic links will do the trick!

Now, so that I can put the finishing touches on it - how do I use the slash "/" character as a replacement character in SED?

I want to insert "../" at the first line of a file.

thanks,
Jeff
 
I want to insert "../" at the first line of a file.
sed -e 's!^!../!'

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Thanks to all, my script is running very nicely now.

Jeff
 
you could have just escaped the space

mk test\ space
cd test\ space
cd ..
rmdir test\ space



--
| Mike Nixon
| Unix Admin
|
----------------------------
 
you could have just escaped the space

mkdir test\ space
cd test\ space
cd ..
rmdir test\ space



--
| Mike Nixon
| Unix Admin
|
----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top