This is an old revision of the document!
bash loop
while / read
This code WILL work on filenames with spaces
- quote “For splits items on a space, regardless of if they’re quoted (if they’re stored in a variable). However, the read command does not.”
ls -1L *.tiff | while read file;do du -h -d 0 "${file}" done
- another example:
ls -1L *.tiff | while read file;do tiff2pdf -p letter -o "${file}".pdf "${file}" done
for
This code will NOT work on filenames with spaces
- note that the symbols used are backticks, not single quotes (backtick is the key left of 1)
for file in `ls -1L`;do du -h -d 0 $file done