Bash for loops, spaces in variables
Andrew Reid
andrew.reid at plug.cx
Mon Nov 27 12:59:08 CST 2006
Suppose I have a bunch of files and directories, like so:
/tmp
/tmp/My Photos
/tmp/Your Photos
/tmp/Her Photos
If I iterate over that list of directories, using something like:
for i in `ls /tmp/*` do
echo $i
done
I get a list like
My
Photos
Your
Photos
Her
Photos
What I need is a for each item to be the complete path.
Unfortunately, I can't alter the input (I'm using vmware-cmd -l for
this task), so I need to do something in the script to make sure
things don't get stuffed up by having spaces in the file names.
Suggestions?
Cheers,
- andrew
--
| Andrew Reid [mailto:andrew.reid at plug.cx]
| Overworked and Underpaid Network Monkey
| C: +61-401-946-813 F: +61-8-8219-0034
More information about the linuxsa
mailing list