I'm writing a shell script in which I need to loop over directories and then loop over files inside them. So I've written this function:
loopdirfiles() {
#loop over dirs
for dir in "${PATH}"/*
do
for file in "${dir}"/*
do
echo $file
done
done
}
The problem is that it echoes something like *path/to/dir/** on empty directories.
Is there a way to use this approach and ignore those kind of directories?