I'm having some issues in a unix shell script I'm trying to write that keeps a running total of the number of lines in multiple files from the command line. I can count the lines individually and display them for each run through the loop but my lines variable always reads 0 at the end.
#! /bin/sh
lines=0
line_count(){
#count the lines
l= blablabla.....
lines=`lines + l`
}
for f in "$@"
do
echo "total lines:"
( line_count "$f" )
done
wc -l file?shor you don't have access towc, How aboutgrep -c '.*'