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
-
UpdatedNov 05, 2014
-
Views48,417
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.