Advertisement

03.12.2008 at 04:06PM PDT, ID: 23237049
[x]
Attachment Details

Perl one liner to remove a line that carries over to another new line which starts with a space

Asked by bt707 in Perl Programming Language

I need a perl one liner, I need to remove some fields from a ldap dump to give to Sun for some troubleshooting, the problem I have is I can remove the lines I need but not everything. The way the ldap records work is if there is a line that carries over to another line there is a space at the first of the line which tell ldap that it is one line.

The ldap dump I have is now just a text file but if I remove the lines I need it does not remove the rest of the line on the attributes I'm removing if there is a carry over to a new line.

Example:

In this part of a example I'm I need to remove the homePostalAddress: which if I remove it a few ways that I know how I just remove the line of homePostalAddress: 65 Millfield Lane,  Nether Poppleton,  York,  YO26 6NB,  Un, but the continuation of that attribute is carried over to the next line so the ( ited Kingdom,) is not removed.


dn: cn=John Doe  100397,ou=employee,o=abc,c=ou
modifyTimestamp: 20080308162306Z
modifiersName: cn=John Doe 100397,ou=employee,o=abc,c=ou
schedule: 2008
schedule: Jan 08-10 : La Defense , Paris , France
schedule: Jan 13-19 : Austin / Houston TX , USA : WS Review
schedule: Mar 09-14 : Brega/Benghazi/Tripoli, Libya
schedule: Mar 18    : London , client visit (Tullow)
schedule: Apr 06-22 : Port Gentil,Pointe Noire,Luanda,Cabinda,J'burg,Cape Town
schedule: Apr28-01May: La Defense / Clamart , Paris
lastModifiedBy: self
homePostalAddress: 65 Millfield Lane,  Nether Poppleton,  York,  YO26 6NB,  Un
 ited Kingdom,
businessCategory: O530-WCS Staff
locationCode: WSV


I'm trying to find a perl one liner where it would make the above example come out to be:


dn: cn=John Doe  100397,ou=employee,o=abc,c=ou
modifyTimestamp: 20080308162306Z
modifiersName: cn=John Doe 100397,ou=employee,o=abc,c=ou
schedule: 2008
schedule: Jan 08-10 : La Defense , Paris , France
schedule: Jan 13-19 : Austin / Houston TX , USA : WS Review
schedule: Mar 09-14 : Brega/Benghazi/Tripoli, Libya
schedule: Mar 18    : London , client visit (Tullow)
schedule: Apr 06-22 : Port Gentil,Pointe Noire,Luanda,Cabinda,J'burg,Cape Town
schedule: Apr28-01May: La Defense / Clamart , Paris
lastModifiedBy: self
businessCategory: O530-WCS Staff
locationCode: WSV


Thanks for any help on thisStart Free Trial
[+][-]03.12.2008 at 04:30PM PDT, ID: 21111884

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]03.12.2008 at 04:38PM PDT, ID: 21111928

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628