Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a large text file with many (~64000) similar lines in it. I would like to create a new file, differing from the original one in the following way:
If a line in the original file has 188 characters, followed by 8 numbers, followed by 16 characters, the corresponding line in the new file must have the 8 numbers replaced with 20020101, unless the original 8 numbers are 00000000, in which case the line is not copied into the new file.
I was thinking of something along the lines of:
perl -lne 'print unless /.{188}00000000.{16}/' original.txt > new.txt
This works for getting rid of the lines with 00000000 in them, but how do I adapt this in order to implement the replacement mentioned above?
Thanks in advance,
S
|
|---|