in reply to match a word and delete last line
#!/usr/bin/perl # http://perlmonks.org/?node_id=1190966 use strict; use warnings; $_ = do { local $/; <DATA> }; s/^(\w+[-_]\d+)\n(?=.*\1\b)//gm; print; __DATA__ Text_1 sample-text file Text_1 matching the 1st line matching the last line Text text_1 text-2 sample-text file text-2 matching the 1st line matching the last line
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: match a word and delete last line
by ArifS (Beadle) on May 23, 2017 at 14:03 UTC | |
by tybalt89 (Monsignor) on May 23, 2017 at 14:17 UTC | |
by ArifS (Beadle) on May 23, 2017 at 14:23 UTC | |
|
Re^2: match a word and delete last line
by ArifS (Beadle) on May 23, 2017 at 13:45 UTC |