Awk

From Linuxintro
Revision as of 15:23, 25 July 2009 by imported>ThorstenStaerk

awk is a command for string operations. For example, it allows you to show only the second column of a file. awk is not a simple command, but rather a programming language on its own. awk and gawk (for GNU awk) are used synonymously.

Examples

Show only the second column of file.txt

awk '{print $2;}' file.txt

kill all processes of a user

ps --no-header -fu <username> | awk '{ print $2 }' | grep -v $$ | xargs kill

See also