Write a script to get the line number of a file with "while read LINE", but failed

#!/bin/sh
num=1
cat $1 | while read LINE
do
        num=`expr $num + 1`
done
echo $num


Source: shell

Leave a Reply