This question already has an answer here:
I have a scenario where all my file patterns are placed in a text file. Now I need to write a shell script to read each and every file pattern name present in the text file and check it it exists in the directory or not. The output should be written to a log file at final.
#!/bin/ksh file="/usr/opt/filenames.txt" mondir=/home/pavan while read line do # display list of files with the pattern in the monitoring directory filename=$line ls -lrt $mondir/$filename* done <"$file"
The above code is listing the files. But i also need to print the count(number of files for each and every filepattern name.