![]() |
|
|
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 |
| shell script to find and replace a line using a identifier | kenray | Shell Programming and Scripting | 7 | 05-06-2009 10:28 AM |
| Find and replace a field in the last line | ChicagoBlues | UNIX for Dummies Questions & Answers | 3 | 10-27-2008 06:02 PM |
| Find and replace some line | johnl | Shell Programming and Scripting | 1 | 05-22-2008 04:54 AM |
| find a shell and replace the line | jvellon | UNIX for Advanced & Expert Users | 1 | 06-13-2006 09:44 PM |
| Search and replace multi-line text in files | marz | Shell Programming and Scripting | 10 | 10-10-2005 09:05 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
multi line multirecord find and replace
Hello
I am looking to have a script that performs some tasks for find and replace and inserts a line as well. I have done some programming 10 years ago, so it is causing me a little grief. File consists of 2500 records. I will show you a sample consisting of two records below and what needs to be replaced and inserted: dn: cn=Marquisd,ou=PTG,ou=MTL,ou=QUE,o=ASDASD changetype: modify ndsHomeDirectory: cn=APMMTL02F25_MRC1,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\ TVG\Chagnonl dn: cn=USERNAME1,ou=PTG,ou=MTL,ou=QUE,o=ASDASD changetype: modify INSERT LINE HERE blah blah blah ndsHomeDirectory: cn=APMMTL02F25_MRC1,ou=SVR,ou=MTL,ou=QUE,o=ASDASD# 0#USAGERS\ TVG\REPLACEHERE basically each of the 2 above are the records. There are 2500 of them to be done. 1) I guess to cut the first line and extract the variable needed eg (Marquisd) 2)locate the end of the second line and insert the extra line to be added 3) locate the text on the end line (after the last slash) and replace this data with the entry obtained from the varialbe above 4) repeat for all the records, and end Thanks! JAMIE Last edited by vbe; 06-25-2009 at 06:29 AM.. Reason: rm URL |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|