So, I have a bash script that combines a series of subdirectories, searches for files containing a specific line, and then prints the total values of the files and the total values of the directory for line entries. The code is as follows.
for dir in $(find * -type d); do
echo "directory: $dir" >> $OUT
for f in $(find $dir/* -type f); do
echo -n "$(basename $f) " >> $OUT
grep -c -h $1 $f >> $OUT
done
echo -n "directory total: " >> $OUT
grep -c -h $1 $dir/*.* | awk '{SUM += $1} END {print SUM}' >> $OUT
done
When he does this, if I read in 10 files, he lists them in a text file as file1.txt, file10.txt, file2.txt , etc.
Is there a way so that I can print the file file1.txt, file2.txt, file3.txt, etc. and actually specify the 10th file?
I'm new to bash, so I'm just wondering if anyone knew about this. Any help is greatly appreciated. And yes, the files are literally called file1.txt, file2.txt, etc. This is basically just for getting familiar with bash scripts.