UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old February 7th, 2005, 04:06 PM
nesimp nesimp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 nesimp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 23 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old February 7th, 2005, 04:12 PM
nesimp nesimp is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 2 nesimp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 23 sec
Reputation Power: 0
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:
Originally Posted by nesimp
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

Reply With Quote
  #3  
Old February 8th, 2005, 04:15 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 49 m 57 sec
Reputation Power: 9
this sure dont work
Quote:
sed 's/add/modify\nDelete:messageserver\n /' c:\ldifs\ms.ldif c:\ldifs\ms_del.ldif

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

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Sed Help Needed


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway