export a=0 while read line ; do a=$(expr $a + 1) done < $file echo $a
Nice to know that bash doesn't fork loops that are being used with redirection, and not piping!