if [ $# -ne 3 ] then echo -e "\tERROR: Invalid number of arguments" else fname=$1 if [ -f $fname ] then if [ -s $fname ] then count=0 len=`wc -l < $fname` i=$2 j=$3 if [ $i -lt 1 -o $j -gt $len ] then echo -e "\tERROR: Invalid limits provided" else while read line do count=`expr $count + 1` if [ $count -ge $i -a $count -le $j ] then echo -e "Line $count: $line" fi done < $fname fi else echo -e "\tERROR: $fname is a Empty File" fi else echo -e "\tERROR: $fname is not a Regular File" fi fi
Search Here
Shell Script to print the content of a text file from it's ith number line to jth line number. The file name, ith number line and jth number line are supplied as command line arguments
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment