Nothing stupid about them...

...I just stole the name from David Letterman's "stupid pet tricks". I hope these tips help you avoid or fix mistakes along the way in your *nix administration duties.

Saturday, April 18, 2009

AIX and its "stanza" structure

Most *nix systems arrange their system data in delimited rows of text files. Pretty simple, eh? Grep for the data you are searching on, then awk out the field you want.

root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin

Not so AIX. This OS favors the "stanza" structure, in which data is presented in this form:

root:
password = XXXXXXXXXXXXX
lastupdate = 1239276751
flags =

joeuser:
password = XXXXXXXXXXXXX
lastupdate = 1239044995
flags =

Ah well, to each their own right? So how do you quickly parse data out of an AIX file? I use this method...probably not the best but it works.

sed -n '/joeuser/,/:/p' /etc/security/passwd

This will return the stanza for joeuser up to and including the next user name below him (:), which you can then grep for whatever field you want.

Search

Google