SimTech has asked for the wisdom of the Perl Monks concerning the following question:
Long time parishioner, finally have a problem that my skills don't have, and a search did not provide a solution... You guys are great... Thanks for the anonymous help.
Have a great many text files... All of which have the pesky ^M for EOL, nothing I can do about that (files are created by an outside program).
I need to search each file, find a match, and replace a word that is two lines below.
Example of text:
__TypeOfAirframe__2_0_Cessna152^M
__StartAltitude__2_0_1200^M
__GearStatus__2_0_Down^M
I want to toggle the gear on all Cessna152s.
For clarity... I used _ as space markers. Imagine the above block is repeated 30 or more times, in hundreds of files. TypeOfAirframe is not always a Cessna, so I don't want to toggle the gear on my 747.
I have had great luck with
perl -pi -e 's/find/replace/g' *.txtBut, I cannot get it to recognize the ^M and spaces to perform a search on the above phrase. HELP?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Find Replace
by kennethk (Abbot) on Dec 15, 2011 at 17:00 UTC | |
by SimTech (Initiate) on Dec 15, 2011 at 18:30 UTC | |
by SimTech (Initiate) on Dec 16, 2011 at 03:43 UTC | |
by graff (Chancellor) on Dec 16, 2011 at 04:08 UTC | |
by kennethk (Abbot) on Dec 16, 2011 at 16:12 UTC | |
by SimTech (Initiate) on Dec 16, 2011 at 06:23 UTC | |
|
Re: Find Replace
by Anonymous Monk on Dec 15, 2011 at 16:47 UTC | |
by SimTech (Initiate) on Dec 16, 2011 at 06:26 UTC | |
by Anonymous Monk on Dec 16, 2011 at 09:09 UTC |