Shell script to display given lines

Script :
#accepts a file name , start and end line via arguments
if [ $# -eq 0 ]
    then
        echo No arguments found
elif [ $# -eq 1 ]
    then
        echo One argument found
elif [ $# -eq 2 ]
    then
        echo Two arg8+uments found
else
    if [ ! -e $1 ]
        then
            echo File does not exixts.
    else
        sed -ne ' '$2','$3'p ' $1
    fi
fi

Output:
root@root:~/os# sh f_test_1.sh test1 2 3
this is a temp file line 2
this is a temp file line 3

Comments

  1. how to search for opposite line numbers like you've searched (2&3)
    but i want to search for (2&1) it is not working

    ReplyDelete

Post a Comment

Popular posts from this blog

Multi-programming with variable number of tasks(MVT) program in C

Multi-programming with fixed number of tasks(MFT) program in C

Linked file allocation program in C.