Deleting some lines from a log file

2007-03-27 Thread Eddine

Hi

I have to clean up a log file.
I want to exclude/delete lines that start with a number or MPRINT :


ENTRY

184
185  
**;
186  *   PGMs Complexes   1 : enable - O : disable
  *;
187  
**;123

188
189   %include pgm.MainComplex.sas; ** Macro principale
Base et Queries **;
NOTE: %INCLUDE (level 1) file E:\IFM
 2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
 2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

269 
+**;
MPRINT(MAINCOMPLEX):
**;



RESULT :

NOTE: %INCLUDE (level 1) file E:\IFM
 2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
 2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

**;


I first tyred to identify all numbers at a beginning of a line, but
for instance when doing a substitution I cannot find the good regex
(for a try :%s/^[0-9]*/TEST/ didn't work).

Can you tell me how I have to do to delete those lines beginning by
numbers or MPRINT from my file ?

Many thanks.

Eddine.


Re: Deleting some lines from a log file

2007-03-27 Thread Tom Whittock

:g/^MPRINT/d
:g/^\d\+/d

should do more or less what you want.

Cheers.

On 27/03/07, Eddine [EMAIL PROTECTED] wrote:

Hi

I have to clean up a log file.
I want to exclude/delete lines that start with a number or MPRINT :


ENTRY

184
185  
**;
186  *   PGMs Complexes   1 : enable - O : disable
   *;
187  
**;123

188
189   %include pgm.MainComplex.sas; ** Macro principale
Base et Queries **;
NOTE: %INCLUDE (level 1) file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

269 
+**;
MPRINT(MAINCOMPLEX):
**;



RESULT :

NOTE: %INCLUDE (level 1) file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
is file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.

**;


I first tyred to identify all numbers at a beginning of a line, but
for instance when doing a substitution I cannot find the good regex
(for a try :%s/^[0-9]*/TEST/ didn't work).

Can you tell me how I have to do to delete those lines beginning by
numbers or MPRINT from my file ?

Many thanks.

Eddine.



Re: Deleting some lines from a log file

2007-03-27 Thread Tim Chase
 Can you tell me how I have to do to delete those lines beginning by
 numbers or MPRINT from my file ?

Though I'm not sure I followed your examples, if this is all you
want, the following should do what your above-summary describes:

  :g/^\(\d\|MPRINT\)/d

That breaks down as

:g/.../ on every line matching the ... pattern
d   delete that line

The ... of ^\(\d\|MPRINT\) means at the beginning of the
line (^) match either a digit (\d) or (\|) the text MPRINT (the
\( and \) are for grouping control as I never remember
whether the beginning-of-line associates with a branch or not, so
I tend to be explicit).

Hope this helps,

-tim




Re: Deleting some lines from a log file

2007-03-27 Thread Eddine

Afterwards It seems so simple with your help
Many thanks  to you Tom, Tim and Vim community !

Eddine

2007/3/27, Tom Whittock [EMAIL PROTECTED]:

:g/^MPRINT/d
:g/^\d\+/d

should do more or less what you want.

Cheers.



Re: Deleting some lines from a log file

2007-03-27 Thread Jean-Rene David
* Eddine [2007.03.27 09:45]:
 ENTRY
 
 184
 185  
 **;
 186  *   PGMs Complexes   1 : enable - O : disable
   *;
 187  
 **;123
 
 188
 189   %include pgm.MainComplex.sas; ** Macro principale
 Base et Queries **;
 NOTE: %INCLUDE (level 1) file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
 is file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.
 
 269 
 +**;
 MPRINT(MAINCOMPLEX):
 **;
 
 RESULT :
 
 NOTE: %INCLUDE (level 1) file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas
 is file E:\IFM
  2005-01\gravure_2007_03_15\BRD_04-11-J\Database\Programs\MainComplex.sas.
 
 **;
 
 (for a try :%s/^[0-9]*/TEST/ didn't work).

You are close. The problem is that this pattern
will match *every* line, since you accept zero or
more digits at the beginning of the line.

Try:

:%s/^[0-9]\+/TEST/

Using \+ instead of * in the pattern will match
one or more instead of zero or more.

Then to also match lines that begin with MPRINT:

:%s/^\([0-9]\+\|MPRINT\)/TEST/

Then to delete them (make sure you undo the
previous substitution...):

:g/^\([0-9]\+\|MPRINT\)/d

HTH,

-- 
JR