Skip to content

Instantly share code, notes, and snippets.

@ozzyjohnson
Created May 12, 2015 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozzyjohnson/cace80d417c76bd4ccd5 to your computer and use it in GitHub Desktop.
Save ozzyjohnson/cace80d417c76bd4ccd5 to your computer and use it in GitHub Desktop.
Filtering the output of Novell eDirectory LDAP queries for CNs, I think.
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