Anyone who have used ldapsearch (you know, that handy dandy tool to query your LDAP-database) in a script, will eventually notice one big problem. For reasons beyond my understanding, the original author of this tool decided that it would be cool to apply line wrapping when output is generated with lines over 76 characters. Guess what, it’s not… I searched on the almighty Internet for a solution and found several, but the following I liked the most.
perl -p00e 's/\r?\n //g' # Example ldapsearch -xLLL -h oh.mighty.ldapserver -b dc=example,dc=com | perl -p00e 's/\r?\n //g'
Why? It’s short, does it’s job fast and perl is widely supported. I found this little gem on a mailinglist, but because it’s so easily overlooked, I posted it here.