From: Graham Sent: 12 December 2004 18:11
Probably a simple one, but I can't figure it...
I want to do some conversions on a set of files in a directory, such as
for file in * do do_something_with $file done
However, I want to do the files in date order, not alphabetically, so I tried
for file in $(ls -tr) etc.
But this only works if the files don't have spaces in their names; "for" breaks them up into space-delimited tokens, which is no use at all. How do I do this (apparently) simple thing?
-- GT
Been there, done that :o) The problem is that bash sees space as a delimiter. You need to temporarily change this by setting the IFS variable. It's all in 'man bash' - somewhere.
Regards,
Keith ____________ You can't solve a problem on the same level you created it. - Albert Einstein