[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: slapcat generate extra "space" characters in LDIF output
- To: Frank Bonnet <f.bonnet@esiee.fr>
- Subject: Re: slapcat generate extra "space" characters in LDIF output
- From: "Mark J. Reed" <markjreed@gmail.com>
- Date: Thu, 9 Sep 2010 12:39:39 -0400
- Cc: openldap-technical@openldap.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=ZeKxFNu7PYW7/ZcdKufMs7F3gdjiVTyp/hT4Jl0aSuc=; b=cKy6XIadwjZpVMYR0b5t6vIsj9HWNOwzhgVjEP3pW25OgY54JISXqrsoSGMG75TXxY t8tNkx9iqr5tx4bGizU2+x3pHlR17UbSk41GRLf1U/Uwp2QduAyWX8Sc55WThrOpBnQ6 qZYQau3+8uOI5suEdf5zD3YaE70sqtP42vOKU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=BW3BdpKT0Zh3hqQ5KcO8lN/ISxk3vF7UIJOObSYCJw+Uh/nd1/N38wJGAD4RZDPxLF hzlxMe5DWCX/Jvr1CEd3dZMLMlSHwUCW7+Gy2dJ9I7/17O2b+RwzhYVsmJL6tHA7qWom nJiDTEd3mqZLypJfpIu+OHfJBLvV4lHUxB7/k=
- In-reply-to: <4C878B00.4090200@esiee.fr>
- References: <4C878B00.4090200@esiee.fr>
FWIW, I use this script to undo the line-folding of LDIF. Just pipe
the output of slapcat or ldapsearch or whatever through it and you'll
get something that's no longer RFC-compliant LDIF but is more amenable
to processing with text-based tools.
#!/usr/bin/perl
# Unfold LDIF so that each attribute is on a single line
my $acc;
while (<>) {
chomp;
if (s/^ //) {
$acc .= $_;
} elsif (/^\S/) {
print "$acc\n" if $acc;
$acc = $_;
} elsif (/^$/) {
print "$acc\n" if $acc;
print "$_\n";
$acc = undef;
}
}
print "$acc\n" if $acc;
Refolding is a one-liner, something like this:
perl -pe 's/^(.{76})(..*)$/$1\n $2/'