Created
May 12, 2015 23:56
-
-
Save ozzyjohnson/cace80d417c76bd4ccd5 to your computer and use it in GitHub Desktop.
Filtering the output of Novell eDirectory LDAP queries for CNs, I think.
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
BEGIN { | |
cn = "" | |
} | |
function trim(field) { | |
gsub(/\r/, "", field) | |
gsub(/^[ \t]+/, "", field) | |
return field; | |
} | |
function trimCN(field) { | |
gsub(/cn=/,"", field) | |
return field; | |
} | |
function secs2days(field) { | |
field = (field/86400) | |
return field; | |
} | |
function convertTime(field) { | |
yy = substr(field,0,4) | |
mo = substr(field,5,2) | |
dd = substr(field,7,2) | |
hh = substr(field,9,2) | |
mi = substr(field,11,2) | |
ss = substr(field,13,2) | |
field = yy"/"mo"/"dd" "hh":"mi":"ss | |
return field; | |
} | |
/^member: / {split($2,a,","); cn = trimCN(a[1]); dn = cn; if ($2 == "") next;} | |
{ printf(cn"\n") | |
cn = "" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment