expand-ldif

March 25, 2010 at 9:34 pm (English, Linux) ()


#!/bin/sh

# Etienne Goyer <etienne.goyer@xxxxxx.com>,
# (but really Marc Tardif; credits where due)
# March 25th 2010

# The LDIF format have this annoying feature that line continue
# if the next one start with a space. Bleh. That makes the work
# of standard Unix command-line text filter terribly complicated,
# and make parsing the output of ldapsearch very unreliable.
# Piping the LDIF through this first should fix it.

awk '/^ / { l=l substr($0, 2); next }; { print l; l=$0 }; END { print l }'

# Yep, that's it!

Permalink 1 Comment