![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to search for keywords in subsequent lines | rdhanek | Shell Programming and Scripting | 12 | 08-11-2009 05:43 AM |
| Delete the lines before the first instance of the keyword | rdhanek | Shell Programming and Scripting | 8 | 07-29-2009 01:07 PM |
| Delete the lines after the last instance of the keyword | rdhanek | Shell Programming and Scripting | 2 | 07-29-2009 01:00 PM |
| replace only 1st word of a line if it comes in the subsequent lines at same postion. | geeko | Shell Programming and Scripting | 9 | 06-03-2009 07:25 AM |
| search 2 lines and delete above line | shamushamu | Shell Programming and Scripting | 4 | 10-06-2008 05:43 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
search for keyword in subsequent lines and delete the second line
I have my data something like this
I need to search for the keyword yyyy in the susequent lines and if it is present, delete the second line with keyword. In other words, if a keywords is found in two subsequent lines delete the second line. input data: Code:
aaaa bbbbb cccc dddd xxxx yyyy xxxxx abc xxxx yyyy xxxxx xyz aaaa bbbbb cccc dddd rrrrrrrrr ttttttt yyyy xxxx yyyy xxxx aaaa bbbbb cccc dddd Code:
output expected: aaaa bbbbb cccc dddd xxxx yyyy xxxxx abc aaaa bbbbb cccc dddd rrrrrrrrr ttttttt yyyy xxxx yyyy xxxx aaaa bbbbb cccc dddd |
![]() |
| Bookmarks |
| Tags |
| keyword, search, subsequent lines |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|