I have a directory of photos whose names are the time and date the photo was taken. E.g:
~$ ls directory -1
2003-09-15 03.30.33.jpg
2004-05-04 12.45.28.jpg
2004-05-04 12.45.51.jpg
However, if I run this command as part of a for
loop, and echo the output, the spaces in the filenames are treated as new lines:
~$ for pic in `ls directory -1` ; do echo "$pic"; done
2003-09-15
03.30.33.jpg
2004-05-04
12.45.28.jpg
2004-05-04
12.45.51.jpg
Why is this happening, and how can I stop it?