Friday, 15 July 2011

linux - listing files from directory by passing command line arguments -



linux - listing files from directory by passing command line arguments -

i trying list files number of directories using command line arguments. trying pass directory paths through command line , display files in searched directories. this. "directory: path1" files files files

"directory: path2" files files

etc.

so using $* pass of command line arguments displays files first listed directory.

#!/bin/bash cd $* filename in * echo "directory: $*" echo $filename done

something similar should work:

dirs=$* dir in $dirs echo "directory: $dir" filename in $(ls $dir) echo $filename done done

linux bash shell unix

No comments:

Post a Comment