useless line feeds in ldapsearch output. Howto remove with shell script?

Hi

$ cat ad.sh 
ldapsearorg -x -LLL -h sb1131z.testbadbigcorp.org -D "CN=ADMINZZ,OU=AdminRoles,DC=testbadbigcorp,DC=org" -w "UT3w4f57lll--4...4" -b "OU=Test,DC=testbadbigcorp,DC=org" "(&(&(&(&(objectCategory=person)(objectClass=user)(lockoutTime:1.2.840.113556.1.4.804:=4294967295)))))" dn
$ ./ms_ad.sh 
version: 1
[...]
 
dn: CN=TEST,OU=TEST,OU=TEST,OU=TEST,OU=TEST,DC=testbadbigcorp,
 DC=org
 
[...]

I have the same problem like Abhishek Srivastava from Cisco:

I am using ldapsearch method to backup the data and writing the output to
some file. If the dn of any object is too long then the same is broken into
two lines. Is there any option to suppress this new line character for long
DN's.

>From ldif file:
*****************************************************
dn: cn=abcd.xyz.rty.aaaa,ou=config,ou=xyzApp,ou=xyzGroups,ou=
 rain106,o=company,c=ountry
**************************************
After "ou=" there is a new line character introduced so rain106 comes into
next line..

source ldapsearch result breaks the long dn's in seperate lines

the answer was

There is no such option to OpenLDAP's ldapsearch. The ldapsearch from the Netscape SDK has a '-T' option to suppress line folding.

is there an other way to remove those line foldings (with shell script)?

How to recognize the lines that were splitted ?

Jean-Pierre.

I don't suppose it checks the value of COLUMNS ? You could pump it up really high.

COLUMNS="5000"
export COLUMNS

you can use some perl to fix the long line issue.
Re: ldapsearch result breaks the long dn's in seperate lines

personally i use the netscape SDK, and this has a -T option.

as for the blank lines, if your only returning the DN, then grep the output for the DN.

in the netscape world i use this kind of thing...

./ldapsearch -1 -T -D "cn=directory manager" -w password uid=blarg dn | grep "^dn:"

---------- Post updated at 03:19 PM ---------- Previous update was at 03:18 PM ----------

you can use some perl to fix the long line issue.
Re: ldapsearch result breaks the long dn's in seperate lines

personally i use the netscape SDK, and this has a -T option.

as for the blank lines, if your only returning the DN, then grep the output for the DN.

in the netscape world i use this kind of thing...

./ldapsearch -1 -T -D "cn=directory manager" -w password uid=blarg dn | grep "^dn:"