Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Vi delete line with second occurence of pattern

$
0
0
I have a large file and many lines are duplicated. I'm trying to delete lines with every second occurrence of a pattern. Did tried searching similar question but no luck.


I can delete all lines matching pattern with :g/pattern/d but don't want to lose data.


Sample pattern to delete John-------Doe
Code:

Sample data:
Time--------FName---------LName
11:05-------John------------Doe
11:05-------John------------Doe
11:06-------Michael---------Lawrence
11:06-------Michale---------Lawrence

Expected result:
11:05-------John------------Doe
11:06-------Michael---------Lawrence


Viewing all articles
Browse latest Browse all 16232

Trending Articles