awk

pattern 匹配

你可以只为匹配特定模式的行执行AWK的命令 例如,下面打印Managers的names和titles:

$ awk -F ',' '/Manager/ {print $2,$3}' employee.txt
Jason Smith IT Manager
Jane Miller Sales Manager

下面的例子打印employee name 哪个Emp id是102:

$ awk -F ',' '/^102/ {print "Emp id 102 is", $2}' employee.txt
Emp id 102 is Jason Smith