I'm running a find on a directory to do certain operations on files. I also want to count how many files were affected, but some strange things have happened in the loop:
COUNTER=0
find . -type f -name "*.txt" | while read f
do
let COUNTER++
echo Counter is $COUNTER # This shows COUNTER working...
done
echo Counter is $COUNTER # COUNTER is back to 0 at this point...
Why is $COUNTER
resetting itself?