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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting useless line feeds in ldapsearch output. Howto remove with shell script?
# 1  
Old 01-24-2012
useless line feeds in ldapsearch output. Howto remove with shell script?

Hi

Code:
$ 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

Code:
$ ./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:

Code:
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

Code:
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)?
# 2  
Old 01-24-2012
How to recognize the lines that were splitted ?

Jean-Pierre.
# 3  
Old 01-24-2012
I don't suppose it checks the value of COLUMNS ? You could pump it up really high.

Code:
COLUMNS="5000"
export COLUMNS

# 4  
Old 01-24-2012
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...
Code:
./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...
Code:
./ldapsearch -1 -T -D "cn=directory manager" -w password uid=blarg dn | grep "^dn:"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove Space and blank line from file in UNIX shell script

I have below file. I want to remove space at begining of every line and then after also remove blank line from file. I use below code for each operation. sed -e 's/^*//' < check.txt > check1.txt sed '/^\s*$/d' < check1.txt > check2.txt above code not remove all the space... (12 Replies)
Discussion started by: Mohin Jain
12 Replies

2. Shell Programming and Scripting

Remove line breaks in csv file using shell script

Hi All, I've a csv file in which the record is getting break into 1 line or more than one line. I want to combine those splits into one line and remove the unwanted character existing in the record i.e. double quote symbol ("). The line gets break only when the record contains double... (4 Replies)
Discussion started by: rajak.net
4 Replies

3. Shell Programming and Scripting

remove line feeds followed by character

Hi everyone, I'm very new to using sed, run through some tutorials and everything but I've hit a problem that I'm unable to solve by myself. I need to remove all linefeeds that are followed by a particular character (in this case a semicolon). So basically, all lines starting with a semicolon... (5 Replies)
Discussion started by: fluffdasheep
5 Replies

4. Shell Programming and Scripting

How to remove particular line from file through shell script?

Hi, I am pasring a file line by line. I need to check each field in line and remove particular line. input file lines are, 02;ABC;PQR 03;aaa;rrr 04;ABC;ggg 09;eee;ABC 04;lmn;stu I am looking for line containing "ABC" as field value. Now How can I remove this line from input file... (7 Replies)
Discussion started by: Poonamol
7 Replies

5. Shell Programming and Scripting

howto place in one line output from two functions

Hi I would like to place in one line output from two functions. Both functions return text with print cmd. When I place above code in script it will place them in series. e.g. 1 #/bin/ksh 2 3 function1() 4 { 5 print "My name is" 6 ... (3 Replies)
Discussion started by: presul
3 Replies

6. Shell Programming and Scripting

Howto return the single penultimate line from my output

Hi All I have what seems to be something quite trivial but for the life of me can't work out a solution. Basically, I have the following script that reads a version report that contains certain flags. If a condition is true, I want to print the value of column 2, sort them uniquely and return... (2 Replies)
Discussion started by: kingpin2502
2 Replies

7. Shell Programming and Scripting

shell script to remove all lines from a file before a line starting with pattern

hi,, i hav a file with many lines.i need to remove all lines before a line begginning with a specific pattern from the file because these lines are not required. Can u help me out with either a perl script or shell script example:- if file initially contains lines: a b c d .1.2 d e f... (2 Replies)
Discussion started by: raksha.s
2 Replies

8. News, Links, Events and Announcements

HOWTO: RSS Feeds for UNIX Forums

If you want to submit your favorite UNIX.COM forum to RSS news feeds registries or directories, here is how: The top level RSS link to the UNIX forums is: https://www.unix.com/external.php This is the default for the RSS type, which is: https://www.unix.com/external.php?type=RSS ... (11 Replies)
Discussion started by: Neo
11 Replies

9. Shell Programming and Scripting

How to remove line from crontab in shell script?

Hi folks, I need to write a rollback script which removes the following line from the crontab: 0 0 * * * su - orca -c "/home/orca/core-<SCHEMA_NAME>/cleanup/CLI/cleanup_BRMS.ksh -c OC4J_RiGHTv_<SCHEMA_NAME>" <SCHEMA_NAME> is parameter. How to do it in ksh? Maybe it's better to backup the... (2 Replies)
Discussion started by: nir_s
2 Replies

10. Shell Programming and Scripting

Remove line feeds

Hi, I have a fixed width flat file which has 1 as the first char and E as the last character. Some of the records have a carriage return /line feeds . how do I remove them? Let me know. Thanks VSK (8 Replies)
Discussion started by: vsk
8 Replies
Login or Register to Ask a Question