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.

AIM:

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.

Program:

echo "enter the filename"

read fname

echo "enter the starting line number"

read s

echo "enter the ending line number"

read n

sed -n $s,$n\p $fname | cat > newline

cat newline

output:

[root@localhost ~]# vi 1s.sh

[root@localhost ~]# ./1s.sh

bash: ./1s.sh: Permission denied

[root@localhost ~]# chmod 777 1s.sh

[root@localhost ~]# ./1s.sh

enter the filename

sales.dat

enter the starting line number

2

enter the ending line number

4

1       computers       9161

1       textbooks       21312           2       clothing        3252