in reply to File editing
perl -i.bak -nwe'(/REx/ .. 0) && print'
Of course, that will print the line that matched the REx. What you really want is hard to tell -- whether you want to start with the line after the REx or whether you want the line with the REx on it, and just starting as soon as the end of the REx matches.
perl -i.bak -nwe'(s/.*REx// .. 0) && print'
That will provide option #2 -- you get everything directly following the REx match, including the text on the same line.
perl -i.bak -nwe'print if $match; /REx/ && $match++'
And this one gives you all of the lines immediately following the line where the REx matched.
All of these examples can also be wrapped in while (<>) { ... } instead of used with the command line switches if necessary.
-dlc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: File editing
by Jonathan (Curate) on Sep 29, 2000 at 14:20 UTC |