How To Iterate Over Files in a Directory¶
ls
is not the command that expands globs to filenames, bash does that.
In the following snippet, bash expands /dev/{s,v}*1
and expands it to /dev/sda1
which is what the for loop is
then passed.
1 2 3 4 5 | # This only works if there are no spaces in the file names. for f in /dev/{s,v}*1 do echo "$f" done |