I am trying to build a script from the command line. But everytime I run, my echo command only prints the directory name and not the files inside the directory.
for EachFile in $1:
do
#Do stuff
echo "Filename is $EachFile"
done
for var in ... iterates over the list of "words" following in, not over files in a directory. To iterate over the files in a directory, you need to convert the list of files in that directory into a list of words, and a shell wildcard expression (like "$dir"/*) is the best way to do that.
for var in ...iterates over the list of "words" followingin, not over files in a directory. To iterate over the files in a directory, you need to convert the list of files in that directory into a list of words, and a shell wildcard expression (like"$dir"/*) is the best way to do that.