Some of my most popular tools are awk and sort (and the usual sed and uniq). But sometimes I would like to have a nice print out from awk in aligned format and sort one of the columns after the padding. Today I found out a nice combination and it shows how to do just what I explained in this nice example of printing out the username and home directory from the /etc/passwd file:

cat /etc/passwd | awk -F\: '{printf "%-20s%-20s\n", $1, $6}' | sort -k
comments powered by Disqus