|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Sed Help Needed
Hello,
I have an ldif file in the following format: dn: cn=AbruzRC,ou=ADVERTISING,ou=HQ,ou=NY,o=NYT changetype: add messageServer: cn=ADV-OA-01,ou=ADVERTISING,ou=BUSINESS,ou=HQ,o=NYTIMES dn:cn=Advuser,ou=ADVERTISING,ou=HQ,ou=NY,o=NYTchangetype: add messageServer: cn=ADV-OA-01,ou=ADVERTISING,ou=BUSINESS,ou=HQ,o=NYTIMES I need to make every entry look as follows: dn: cn=AbruzRC,ou=ADVERTISING,ou=HQ,ou=NY,o=NYT changetype: modify delete: messageServer messageServer: cn=ADV-OA-01,ou=ADVERTISING,ou=BUSINESS,ou=HQ,o=NYTIMES dn:cn=Advuser,ou=ADVERTISING,ou=HQ,ou=NY,o=NYTchangetype: modify delete: messageServer messageServer: cn=ADV-OA-01,ou=ADVERTISING,ou=BUSINESS,ou=HQ,o=NYTIMES I have been trying the following: sed 's/add/modify\nDelete:messageserver\n /' c:\ldifs\ms.ldif c:\ldifs\ms_del.ldif Any help would be greatly appreciated. This is a windows machine however I felt I would get more help in the unix forum. Thanks |
|
#2
|
|||
|
|||
|
Sorry file has entries that look like:
dn: cn=AbruzRC,ou=ADVERTISING,ou=HQ,ou=NY,o=NYT changetype: add messageServer: cn=ADV-OA-01,ou=ADVERTISING,ou=BUSINESS,ou=HQ,o=NYTIMES Need to change to dn: cn=AbruzRC,ou=ADVERTISING,ou=HQ,ou=NY,o=NYT changetype: Modify Delete: messageServer messageServer: cn=ADV-OA-01,ou=ADVERTISING,ou=BUSINESS,ou=HQ,o=NYTIMES Quote:
|
|
#3
|
|||
|
|||
|
this sure dont work
Quote:
there are two probls: the sed statement and the parameters sed (if not redirected) prints on stdout sed sed-cmd inputfile >outputfile # does what you want the statement (not really tested) i did not spend time to do it on a cmd-line, put this in file then use sed -f thatfile inputfile > outputfile pay attention to the newlines, after 'a\' and '.*Server' they are NEEDED -------------start here(not included) /changetype: add/{ s/add/Modify/;a\ Delete: messageServer } ----------- stop here(not included) pay attention to spaces AND chars case |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Sed Help Needed |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|