linux - getting filenames from directory in shell script -


i iterate loop on file present in directory using shell script. further, display contents each file. passing directory command line argument.

i have simple loop follows:

for file in $1     cat $file done 

if run

sh script.sh test 

where test directory, content of first file only.

could please me in this?

couple of alternatives:

compact modification of sma's code:

for file in $1/*        [[ -f $file ]] && cat $file  done 

or use find:

find $1 -type f -exec cat \{\} \; 

Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -