You are on page 1of 1

vi nmark(enter)

rollno:name:m1:m2:m3:dob
10:abcd:40:60:90:1992
20:lmno:80:80:80:1993
30:pqrs:24:25:26:1994
40:bcde:70:25:80:1995
50:uvwx:90:80:70:1996

1)
[mscit2011@xyz mscit2011]$ sed '3q' mmark (display 3 lines and quit)
rollno:name:m1:m2:m3:dob
10:abcd:40:60:90:1992
20:lmno:80:80:80:1993
2)
[mscit2011@xyz mscit2011]$ sed '3p' nmark(it will print all the lines)
rollno:name:m1:m2:m3:dob
10:abcd:40:60:90:1992
20:lmno:80:80:80:1993
30:pqrs:24:25:26:1994
40:bcde:70:25:80:1995
50:uvwx:90:80:70:1996
3)[mscit2011@xyz mscit2011]$ sed -n '3p' nmark(it will print the 3rd line)
20:lmno:80:80:80:1993
4)[mscit2011@xyz mscit2011]$ sed -n '1,2p' nmark(it will print 1 n 2nd line)
rollno:name:m1:m2:m3:dob
10:abcd:40:60:90:1992
5)[mscit2011@xyz mscit2011]$ sed '$p' nmark
rollno:name:m1:m2:m3:dob
10:abcd:40:60:90:1992
20:lmno:80:80:80:1993
30:pqrs:24:25:26:1994
40:bcde:70:25:80:1995
50:uvwx:90:80:70:1996

6)[mscit2011@xyz mscit2011]$ sed -n '5p' nmark (it will print 5th line)
40:bcde:70:25:80:1995
7) [mscit2011@xyz mscit2011]$ sed -n -e '1p' -e '3p' nmark(it will prnt 3rd n 1s
t line)
rollno:name:m1:m2:m3:dob
20:lmno:80:80:80:1993

You might also like