Posts Tagged ‘AWK’

Basic AWK usage in BASH

To print a field from a file (-F is the field separator and $ is the number of the field to print): awk -F’:’ ‘{ print $1 }’ /etc/passwd or awk -F’:’ ‘{ print $1 $3 }’ /etc/passwd or awk -F’:’ ‘{ print “username: ” $1 “\t\tuid:” $3″ }’ /etc/passwd