This is an old revision of the document!
bash loop
- This example will loop through all files and folders, and determine their disk usage (note that this particular example can actually be done without a bash loop, using only the du command)
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
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