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!
Written by Christian Romney
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#