Mailinglist Archive: opensuse (2800 mails)
| < Previous | Next > |
Re: [opensuse] Reg. expression
- From: Jan Karjalainen <jrock@xxxxxxx>
- Date: Thu, 08 Feb 2007 00:51:43 +0100
- Message-id: <45CA660F.2080207@xxxxxxx>
Randall R Schulz wrote:
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
Jan,The word LOG appears somewhere 2/3 in the line...
On Wednesday 07 February 2007 15:30, Jan Karjalainen wrote:
...
On Wednesday 07 February 2007 15:19, Jan Karjalainen wrote:I found the expression: .+LOG.+
I'm trying to parse through a file and delete all the lines with...
the word "LOG" on it, eg. replace it with "".
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).
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
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
Randall Schulz
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
| < Previous | Next > |