I am trying to list files from any number of directories by using command line arguments.
I am trying to pass the directory paths through the command line and display files that are in searched directories. Something like this.
“Directory: PATH1”
files
files
files
“Directory: PATH2”
files
files
etc.
So I am using $* to pass all of the command line arguments but it only displays files from the first listed directory.
#!/bin/bash
cd $*
for filename in *
do
echo "Directory: $*"
echo $filename
done
Something similar to this should work: