Very new to Bash and pretty confused about local/global variables/subshells. I'm not sure why the modified variables won't print out at the end of the function—I'm trying to print out a final line count and file count at the end of the file, but if I do, it only prints out 0 because they are local variables. Is there any way to print out the modified values?
count=0
files=0
find . -type f | while IFC= read -r file;
do
let files=files+1
wc -l $file
count=$(($count+$(wc -l < $file)))
echo "total lines $count ; total files $files"
done
echo $files $count
exit 0