Feel the awk power

Some of my favorite AWK expressions:

OSD_LISTEN_PORTS:$(netstat -tlpn | awk -F ":" '/ceph-osd/ { sub (" .*", "", $2); print $2 }' | uniq)
NETWORK=$(ip -4 -o a | awk '/eth0/ {print $4}')
IP=$(ip -4 -o a | awk '/eth0/ { sub ("./..", "", $4); print $4 }')


Because grep foo | awk '{print $1}' is not elegant!

Comments