Skip to content

Instantly share code, notes, and snippets.

@Temikus
Created May 11, 2013 14:51
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 Temikus/5560165 to your computer and use it in GitHub Desktop.
Save Temikus/5560165 to your computer and use it in GitHub Desktop.
Awk script to make the dhcp.leases more readable
awk ' { out = ""} \
{ $1=="lease"||$1=="client-hostname" ? out=" " $2 : out=out } \
{ $1=="binding"||$1=="hardware" ? out= " " $3: out=out } \
{ $1=="ends"? out=" " $3 " " $4: out=out } \
{ $1=="}"? out="\n": out=out } \
{ printf out," " }' dhcpd.leases \
| grep active \
| sed -e s/'[{};" ]'/\ /g \
| awk '{ printf "%-15s %-17s %-10s %-5s\n", $1, $5, $2, $3 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment