This is an old revision of the document!


bash loop

  • :-) 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
  • :!: 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
  • docs/bash/bash_loop.1179164746.txt.gz
  • Last modified: 2008/08/03 00:25
  • (external edit)