I’m trying to figure out how to get total number of lines from all .txt files. I think the problem is on the line 6 -> let $((total = total + count ))
. Anybody knows what’s to correct form of this?
#!/bin/bash
total=0
find /home -type f -name "*.txt" | while read -r FILE; do
count=$(grep -c ^ < "$FILE")
echo "$FILE has $count lines"
let $((total = total + count ))
done
echo TOTAL LINES COUNTED: $total
Thank you