If I want to loop over a statically assigned directory I can do:
cd /path/to/directory
for file in *
do
echo 'Found file' $file
done
If I wanted to pass the directory as an argument, then I could:
cd $1
for file in *
do
echo 'Found file' $file
done
If I move the $1 argument into the loop, I get an error, because it's not an array:
for file in $1
do
echo 'Found file' $file
done
Is there a better way to do this without having to cd into the directory first?