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
-
UpdatedOct 23, 2014
-
Views2,405
You May Like
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.