exrd_q
Last Updated: February 25, 2016
·
1.563K
· christianromney

Slim down your shell pipeline with Awk

Ever pipe a file to grep in order to limit the output to matching rows only to pipe it to awk so you can print a single column? Perhaps like this:

$ netstat -tn | grep tcp | awk '{print $6}' | sort | uniq -c

Save a couple of keystrokes by having awk pull double-duty:

$ netstat -tn | awk '/tcp/ {print $6}' | sort | uniq -c

Happy Awking!