Sunday 10 August 2014

Write a shell script that accept the file name, starting and ending line number as an argument and display all the lines between the given line number.


if [ $# -ne 3 ]
then
echo "Pass minimum three arguments"
exit
fi
c=`cat $1 | wc -l`
if [ $2 -le 0 -o $3 -le 0 -o $2 -gt $3 -o $3 -gt $c ]
then
echo "Invaid Input"
exit
fi
sed -n "$2,$3p" $1

1 comments:

Anonymous said...

what is the output for this program?

Post a Comment

 
- |