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

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -