Bash for loops, spaces in variables
Alphax
alphasigmax at gmail.com
Wed Nov 29 12:43:57 CST 2006
Andrew Reid wrote:
> 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?
>
Just for fun, try "echo ${i}"...
--
Alphax
Death to all fanatics!
Down with categorical imperative!
OpenPGP key: http://tinyurl.com/lvq4g
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 569 bytes
Desc: OpenPGP digital signature
Url : http://www.linuxsa.org.au/pipermail/linuxsa/attachments/20061129/084d8e39/signature.bin
More information about the linuxsa
mailing list