Fedora And Red Hat System Administration/Awk Scripting

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Awk - A Data Driven Programming Language[edit | edit source]

Under Construction

Using Awk at the Command Line[edit | edit source]

Under Construction

Awk Scripts[edit | edit source]

Parsing User Information from passwd data[edit | edit source]

/usr/local/bin/bash-users.awk

#!/bin/awk -f
BEGIN {
    FS = ":"
    USER_COUNT = 0
}

/:\/bin\/bash$/ {
    ++USER_COUNT
    print $1
}

END {
    print USER_COUNT " bash users."
}

Usage:

[user@station user]$ getent passwd | bin/bash-users.awk
root
jkupferer
mesa
user
4 bash users.