Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pasting text after matching lines 1

Status
Not open for further replies.

unixchiq

MIS
Apr 25, 2008
2
US
I have an ldif file from one directory that I need to massage to use to import the users into another directory type.

I need to add the same 5 lines of text into each user's block of information after the first line (which consists of their dn.) Each user's dn ends in the same text (dc=com).

Any idea how I might accomplish this? I could easily put those 5 lines of text at the beginning of the ldif, or else have them in a separate file.

I've already figured out how to do a bunch of other mods that are needed, using sed, but I'm not sure how to do this one.

Thanks,
Samantha
 
You could use awk for this, e.g.

Code:
awk '
    1 # prints all lines
    /dc=com/ {
        print "new data 1"
        print "new data 2"
        print "new data 3"
        print "new data 4"
        print "new data 5"
    }
' inputfile > outputfile

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top