This question already has an answer here:
I need to iterate through every file inside a directory. One common way I saw was using the for loop that begins with
for file in *; do. However, I realized that it does not include hidden files (files that begin with a "."). The other obvious way is then do something like
for file in `ls -a`; do
However, iterating over
ls is a bad idea because spaces in file names mess everything up. What would be the proper way to iterate through a directory and also get all the hidden files?