i=0 while read -r line; do i=$((i+1)) done < file echo $i
With a file containing:
Alpha Beta Gamma Delta Epsilon
The above script prints: 5
5