Meanning :-
Quits after reading 3 lines.
$ sed ‘1,3p’ /etc/passwd
Sed by default prints all lines it processed on standard output. A p command will cause line 1 to 3 be printed twice
$ sed –n ‘1,3p’ /etc/paswd
It suppresses duplicate lines. Remember to user –n whenever using p command.
$ sed –n ‘9,11p’ /etc/passwd
Selects lines numbers 9 through 11.
The s (substitute) helps us in replacing a pattern in the file with something else. The syntax is -
s/
$ sed ‘1,5s/director/member /’emp.lst
The instruction replaces the left-most occurrence of the string director in the current line with the string member
$ sed ‘s/:/ /g’ /etc/passwd
Replaces all occurrences of : with a space with the g flag.
No comments:
Post a Comment