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
#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
how to search for opposite line numbers like you've searched (2&3)
ReplyDeletebut i want to search for (2&1) it is not working