Mailinglist Archive: opensuse (2800 mails)

< Previous Next >
Re: [opensuse] Reg. expression
  • From: David Haller <opensuse@xxxxxxxxxx>
  • Date: Thu, 8 Feb 2007 23:28:34 +0100
  • Message-id: <20070208222834.GB4774@xxxxxxxxxxxxxxxxxx>
Hello,

On Wed, 07 Feb 2007, Randall R Schulz wrote:
>On Wednesday 07 February 2007 15:30, Jan Karjalainen wrote:
[..]
>> I found the expression: .+LOG.+
>
>You're still making it too complicated for programs such as ed, vi,
>grep, egrep or sed, patterns are not required to match the whole line.
>That means the ".+" parts are redundant. If you really want to exclude
>from treatment those lines where "LOG" occurs at the beginning or end,
>then use the pattern ".LOG." (sans quotes, of course).

That means 'one arbitrary character' "LOG" 'one arbitrary character',
which is something else.

>Under some circumstances regular expression efficiency matters little,
>but given the size to which log files can grow, more efficient regular
>expressions are worth using.
>
>So here's what you want to do:
>
>% sed -e '/LOG/d' originalLogFile >filteredLogFile

fgrep -v 'LOG' originalLogFile >filteredLogFile

>If you really want to exclude those lines where LOG occurs at the
>beginning or end, then use this:
>
>% sed -e '/.LOG./d' originalLogFile >filteredLogFile

fgrep -v '^LOG\|LOG$' originalLogFile >filteredLogFile

-dnh

--
Fertility is hereditary. If your parents didn't have any children,
neither will you.
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups