For loops, Spaces in values

Andrew Reid andrew.reid at plug.cx
Mon Nov 27 22:55:30 CST 2006


Suppose I have a program that returns a list of files, but those  
files contain spaces:

/tmp/My File One.txt
/tmp/My File Two.txt

If I try and do a for loop over it, like:

for i in `listdirs` do
echo $i
done

(where list dirs is the program that generates the aforementioned  
output), I get the following output from the loop:

My
File
One.txt
My
File
Two.txt

So, how do I get the for loop to iterate over my list, but not  
delimit that list by spaces?

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