A useful option of sed command to replace multiple lines with a single line upon matching a given string.
$ cat -n file.txt
Hello world
Hello nobody
nobody
Somebody
anybody
If you want to replace the lines 2 and 3 with another line "Hello everybody" the below command will help.
$ sed '/nobody$/{N;s/Hello nobody\nnobody/Hello everybody/}' file.txt
$ cat -n file.txt
1 hello world
2 Hello everybody
3 Somebody
4 anybody
Subscribe to:
Post Comments (Atom)
AT&T USA | Internet not working | Fix by custom APN
If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...
-
Hi there, You all know how to check TCP port connectivity from a Linux or UNIX machine to a remote machine using telnet as per th exampl...
-
Before you start Ensure that you have installed wvdial, usbmodeswitch and usbmodeswitch_data # dpkg -l | grep wvdial # dpkg -l | grep ...
-
1. Open Applications -> System -> Configuration Editor from the GUI OR Open a terminal, type gconf-editor 2. Go to "...
No comments:
Post a Comment