DISQUS

DanNorris.com: Concatenating lines in ldapsearch results

  • Simon Haslam · 1 year ago
    Very handy Dan. It hadn't actually occurred to me that you could always use Perl from the Oracle home before - I do often find myself having to do some sort of "munging" across multiple lines and Perl is probably the easiest tool for the job.
  • Dan Norris · 1 year ago
    Thanks! ...and thanks for stopping by!
  • J. Ayme · 8 months ago
    So usefull !!!

    I got this issue with dipassistant boostrap (line breaks) and incorrect changetype attribute

    Thanks Dan !
  • Dan Norris · 8 months ago
    Glad it was helpful. Thanks for stopping by!

    Please excuse my typos, I sent this from my iPhone.
  • sbutler · 5 months ago
    I was having a problem with this script. It doesn't handle the situation where the continuation line contains spaces. Here's a better version:

    $cnt=0;
    while ($line = <>) {
    chomp($line);
    if ( $line =~ /^authpassword/ ) {
    next;
    } elsif ( $line =~ /^\S+/) { ### this line is a "normal" or starting line
    $results[$cnt++] = $line;
    } elsif ( $line =~ /^$/ ) { ### this line is blank
    $results[$cnt++] = "";
    } elsif ( $line =~ /^\s+(\S.*)/ ) { ### this line is a continuation
    $results[$cnt-1] = $results[$cnt-1] . $1;
    }
    }

    for $i (0 .. $cnt) {
    print "$results[$i]\n";
    }