-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 27-Mar-07, at 9:01 AM, Eddine wrote:
Hi I have to clean up a log file. I want to exclude/delete lines that start with a number or "MPRINT" :
{snippage}
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 ?
You were close. Try :g/^\d\|^\(MPRINT\)/dUsing :g/regex/d to delete whole lines that contain /regex/ I find a lot easier than
:%s/regex.*\n// which accomplishes the same thing Using \d instead of [0-9] I think is easier too.For what it's worth, I find it really helpful to play with regexes just using /regex/ and looking at the resulting highlighted areas. Once you get just what you want you just do a :%s// or :g// and it fills in the last used regex.
For example - try your regex of /^[0-9]*/ then change it to /^[0-9].*/ HTH Brian -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (Darwin) Comment: Verify this email or encrypt your email for free - see gnupg.org iD8DBQFGCSTjGnOmb9xIQHQRAtLeAJ992I/JzEP+5bvAMkEoECJqBAMXGQCgmbm0 7ON4v88jNJ/rIi0/hKfOonA= =5pm2 -----END PGP SIGNATURE-----
