Awk
From Linuxintro
Revision as of 07:02, 27 September 2013 by 95.113.201.142 (talk)
awk is a command for string operations. For example, it allows you to show only the second column of a file. 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
extract eth0's MAC address from ifconfig output
ifconfig | grep eth0 | awk '{ print $5 }'