![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl Search and replace entire line | insania | Shell Programming and Scripting | 1 | 05-22-2008 03:45 PM |
| Perl: Search for string on line then compare numbers! | Crypto | Shell Programming and Scripting | 2 | 01-21-2008 09:50 PM |
| how to insert line break + string in vi (search & replace ) | umen | Shell Programming and Scripting | 1 | 06-08-2006 08:42 AM |
| Perl: Search for string then parse next line | pondlife | Shell Programming and Scripting | 4 | 04-06-2006 01:44 AM |
| Search and replace multi-line text in files | marz | Shell Programming and Scripting | 10 | 10-10-2005 05:05 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Perl: Search for string on line then search and replace text
Hi All,
I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData ReplaceMe moreData moreData 3. MatchText_randomNumberOfText moreData ReplaceMe moreData moreData 4. TextTextText_randomNumberOfText moreData ReplaceMe moreData moreData The above is an example of four lines. I want to find all the lines containing "MatchText" (lines 1,2 and 3) and replace the "ReplaceMe" in that line with "REPLACED". "ReplaceMe" occurs multiple times in lines I do not want to replace it in (as in line 4 above) Hope that makes sense!! Many thanks |
| Forum Sponsor | ||
|
|