How do i keep a variable value after a while loop?
My intention here is to put a if clause within the while to count each time an operation has been done, but isn't working since the count resets after each while loop.
count=0
for file in $(ls /path)
do
cat $ file | while read line
do
count=$((count+1))
echo $count
done
done
echo $count #This echoes 0, even though the inner echo shows each sum.