SED Help

Jason Dixon jason at dixongroup.net
Sun May 16 19:30:15 UTC 2004


On May 16, 2004, at 10:27 AM, Mike Vanecek wrote:

> On Sun, 16 May 2004 10:12:21 -0400, Jason Dixon wrote
>> I'm not a sed expert, but I'm guessing it's behaving "greedy",
>> similar to perl regex.  The first SRC actually falls within the ".*"
>> portion of your match, and the last match is what counts.
>
> I thought it would pick up the first?  If I change the second SRC to 
> SRX, then
> it does pick up the first one.

Right.  As I explained, the .* is greedy.

> What do I need to specify to make it pick up the first one?

No clue, I only use sed for very basic one-liner substitutions.  I'd 
suggest using perl and split()-ting up your stdin to an array.  Let me 
know if you need assistance with this.  You can always look in my 
Hatchet code (http://www.dixongroup.net/hatchet) for ideas.  It's for 
OpenBSD PF logs, but the concepts are the same.

--
Jason Dixon, RHCE
DixonGroup Consulting
http://www.dixongroup.net






More information about the redhat-list mailing list