the blog of napsy

awk awesomeness

Now awk is something that every sysadmin/developer should know. Just for an example, we want to get a list of file sizes that belong to the user luka, we would do: ls -l | grep ^- | awk ' $3 == "luka" { printf("size is %s\n", $5) }' A more practical example to print out Linux users that don’t have a password set: cat /etc/passwd | awk -F: 'BEGIN {C=0} $2 == "" {printf("Password for user '%s' not set\n", $1); C++} END { printf("%d users do no have a password\n", C)} ... read more »