The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-25-2009
cdc01 cdc01 is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 3
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
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0