awk - 报告生成器,拥有强大的文本格式化能力。
awk基础
awk [option] 'program' file1,file2,file3....
对于program来说,还可以细分成pattern和action
[root@localhost logs]# awk --help
用法: awk [POSIX 或 GNU 风格选项] -f 脚本文件 [--] 文件 ...
用法: awk [POSIX 或 GNU 风格选项] [--] '程序' 文件 ...
POSIX 选项: GNU 长选项:
-f 脚本文件 --file=脚本文件
-F fs --field-separator=fs
-v var=val --assign=var=val
-m[fr] val
-O --optimize
-W compat --compat
-W copyleft --copyleft
-W copyright --copyright
-W dump-variables[=file] --dump-variables[=file]
-W exec=file --exec=file
-W gen-po --gen-po
-W help --help
-W lint[=fatal] --lint[=fatal]
-W lint-old --lint-old
-W non-decimal-data --non-decimal-data
-W profile[=file] --profile[=file]
-W posix --posix
-W re-interval --re-interval
-W source=program-text --source=program-text
-W traditional --traditional
-W usage --usage
-W use-lc-numeric --use-lc-numeric
-W version --version
提交错误报告请参考“gawk.info”中的“Bugs”页,它位于打印版本中的“Reporting
Problems and Bugs”一节
翻译错误请发信至 translation-team-zh-cn@lists.sourceforge.net
gawk 是一个模式扫描及处理语言。缺省情况下它从标准输入读入并写至标准输出。
范例:
gawk '{ sum += $1 }; END { print sum }' file
gawk -F: '{ print $1 }' /etc/passwd
|