[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: ldapseaarch goes newline with long lines



On Mon, 10 Mar 2003, Pierangelo Masarati wrote:

> Short: no, no.  ldapsearch(1) writes output according to LDIF1 (RFC2849)
> which, according to note (2) allows folding values at any char; ldapsearch
> chooses colum 78 as the last one.  You may unfold values by using an
> appropriate postprocessing of ldapsearch output, e.g. an awk script
> like
>
> /^dn: / {
>     prev = $0;
>     while ($1 != "") {
>         getline;
>         if (substr($0,1,1) == " ") {
>             prev = prev substr($0,2,length($0)-1);
>         } else {
>             print prev;
>             prev = $0;
>         }
>     }
>     print "";
> }

One line of Perl:

perl -p -0040 -e 's/\n //'

-p:	Loop for each line and print
-0040:	Set input delimiter to 040 i.e. space
-e:	Command follows - strip newline/space sequence.

Who says newlines have to terminate records :-)

-- 
Dave Horsfall  DTM  VK2KFU  daveh@ci.com.au  Ph: +61 2 9906-7866  Fx: 9906-1556
Corinthian Engineering, Level 1, 401 Pacific Hwy, Artarmon, NSW 2064, Australia