Created
September 22, 2019 09:18
-
-
Save sdrik/09866de2b48165de445ab564500d56af to your computer and use it in GitHub Desktop.
Prettify LDIF output in BASH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function ldif_decode { | |
| if [[ "$1" =~ ^([^:]*)::\ (.*)$ ]] | |
| then | |
| echo "${BASH_REMATCH[1]}: $(base64 -d <<< "${BASH_REMATCH[2]}")" | |
| else | |
| echo "$1" | |
| fi | |
| } | |
| function pretty_ldif { | |
| local IFS="" | |
| local prev_line="" | |
| local line | |
| while read -r line | |
| do | |
| if [ "${line:0:1}" = " " ] | |
| then | |
| prev_line="${prev_line}${line:1}" | |
| else | |
| ldif_decode "${prev_line}" | |
| prev_line="${line}" | |
| fi | |
| done | |
| ldif_decode "${prev_line}" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment