![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl Search and replace entire line | insania | Shell Programming and Scripting | 1 | 05-22-2008 06:45 PM |
| Perl: Search for string on line then compare numbers! | Crypto | Shell Programming and Scripting | 2 | 01-22-2008 01:50 AM |
| how to insert line break + string in vi (search & replace ) | umen | Shell Programming and Scripting | 1 | 06-08-2006 11:42 AM |
| Perl: Search for string then parse next line | pondlife | Shell Programming and Scripting | 4 | 04-06-2006 04:44 AM |
| Search and replace multi-line text in files | marz | Shell Programming and Scripting | 10 | 10-10-2005 08:05 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | 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 |
|
||||
|
Thanks a million, great stuff
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| gnu sed, perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|