Design and Develop a shell script to count number of line in a file without using WC

AIM:

 Design and Developa Programe to count number of line in a file without using WC

Program:

# !/bin/sh
Echo “enter a file”
read fname
exec < $faname
flag = 1
nol = 0
now = 0
while read line
do
nol = `expr $nol   1`
now = ‘expr $now   $#’
done
echo “no of lines  = ” $nol
echo “no of records =” $now

Output:

ostudent@ubuntu:~$sh ad2.sh
enter a file
ff
no of lines:2
no of records:0