[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] NewbieQ Perl filtering question
- Subject: [ale] NewbieQ Perl filtering question
- From: fletch at phydeaux.org (Mike Fletcher)
- Date: Fri, 30 Jun 2006 09:29:05 -0400
- In-reply-to: <[email protected]>
- References: <[email protected]>
On Jun 29, 2006, at 4:57 PM, Mills, John M. wrote:
> ALErs -
>
> I need to return only the part of a text line that falls between two
> expected character strings, as it:
>
> Input: blah..blah..string1<good content>string2..garbage..garbage
> Output: <good_content>
The one-liner from the command line version would be:
perl -lne '/string1(.*?)string2/ && print $1' infile > outfile
or to do it in-place (making a copy of the original infile in
infile.bak)
perl -i.bak -lne '/string1(.*?)string2/ && print $1' infile