awk One-Liners

(This is a work in progress)

Get the average of a column

ls -l | grep -v total | awk -F' ' '{sum += $5 } END { print "AVG=", sum/NR }'

Print a file with line numbers

awk '{ print FNR "\t" $0 }' file

Print number of lines in a file (analogous to wc -l)

awk 'END { print NR }'

Comments

Popular posts from this blog

SSH Private Keys - RSA vs. OpenSSH

Google Wifi and Verizon FiOS