in reply to search and replace on a line by line basis
would work. Theoretically you could use lookahead and such to negate the need of capturing parens (Upd: As ishnid shows).perl -lne 'print if s/^(.{188})[1-9]\d{7}(.{16})$/${1}20020101$2/' ori +ginal.txt > new.txt
There is probably a way to do it in one regexp, but I can't think of it now, so if zero at the start is a possibility.
untested, but should work.while(<>) { next unless /^(.{188})(\d{8})(.{16})$/; print $1,"20020101$3\n" unless $2 eq '00000000'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: search and replace on a line by line basis
by MidLifeXis (Monsignor) on Apr 15, 2004 at 17:10 UTC | |
by Anonymous Monk on Apr 16, 2004 at 05:15 UTC |