Help with sed command

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with sed command

Nisha
Hi Guru,

Just read your post "sed - 25 examples to delete a line or pattern in a file ", its awesome , need some help though

how to delete a pattern line and 2 lines below it only if the third line is a blank eg.

Servername
data1
<blank line>

Thanks in advance
Nisha
Reply | Threaded
Open this post in threaded view
|

Re: Help with sed command

Guru
Administrator
Something like this:

$ cat file
Cygwin
Unix
Linux

Solaris
Unix
AIX
xyz
abc


The pattern here is 'Unix':

$ sed '/Unix/{N;N;/\n$/d;}' file
Cygwin
Solaris
Unix
AIX
xyz
abc
Reply | Threaded
Open this post in threaded view
|

Re: Help with sed command

Nisha
Hey, Thanks a lot for quick reply, it works :D :D

Kind Regards,
Nisha
Reply | Threaded
Open this post in threaded view
|

Re: Help with sed command

Guru
Administrator
Hi Nisha
  Did not read your entire original post. Thanks for your feedback on the article.

Guru.