-
Notifications
You must be signed in to change notification settings - Fork 0
Linux awk
harryfyodor edited this page Jul 21, 2017
·
2 revisions
1.1
awk '$3 > 0 { print $1, $2 * $3 }' emp.data
AWK程序的结构 pattern { action }
运行AWK程序 awk 'program' input files 运行文件中的AWK程序 awk -f progfile optional list of files
1.2 $0 一整行 NF 字段的数量 $NF 最后一个字段的值 NR 行号
1.3 格式化输出
{ printf("total pay for %-8s is $%.2f\n", $1, $2 * $3) }
%-8s 左对齐8个空格 $%.2f 两位结尾浮点数
1.4 选择 通过pattern BEGIN & END