I have a script as below.
mount=/transfer/input
rm src/cb.log
array=( $(find ${mount} -type f \( -name "Turbine_DATA*" -o -name "GT_Data*" -o -name "INSIGHTS_data*" \) -printf '%f\n' ))
for i in "${array[@]}";do
echo $i >>src/cb.log
Filecount=`find ${mount} -maxdepth 1 -type f -name "$i" | wc -l`
echo $Filecount>> src/cb.log;
done
I am facing below issue. Although the file Turbine_DATA has 3 lines of data in that but the Filecount is still showing as 1. I am able to do wc -l on that file in the /transfer/input directory where the file is present and I can see 3 count there.
The point to note here that I am running the script from /NAS/Files directory. Is this the problem here?
CodePudding user response:
Filecount is the number of files, not the total number of lines in those files. That's why it's named Filecount, not Linecount. It's counting the number of files with the given name (I assume there can be multiple files of the same name in different subdirectories).
However, for a correct understanding you should probably consult the author of that script - it's not clear what information it should write to cb.log.