Iterating over files

Set the nullglob option to avoid * being treated as literal file name when the directory is empty:

shopt -s nullglob
for f in *; do
    ...
done

Note: this snippet is taken from this article.