exrd_q
Last Updated: February 25, 2016
·
1.375K
· christianromney
4d4539a5c326b9fc26e8b1fa1a850df1

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!

Say Thanks
Respond