I wanted to make a quick script to count the number of lines my .scala files have:
#!/bin/bash
counter=0;
find -iname "*.scala" | while read f; do
lc=$(cat $f | wc -l);
counter=$((counter+lc));
echo "$lc $counter";
done
echo "final result: $counter";
But unfortunately this prints
20 20
204 224
212 436
final result: 0
What's wrong here?