Shell文本处理三剑客之awk
awk 是一个文本处理工具,通常用于处理数据并生成结果报告。其命名源于三位创始人姓氏首字母:Alfred Aho、Peter Weinberger、Brian Kernighan。
语法:
awk [options] 'BEGIN{} pattern {commands} END{}' file
stdout | awk [options] 'BEGIN{} pattern {commands} END{}'
说明:
options
选项BEGIN{}
正式处理数据之前执行pattern
匹配模式{commands;...}
处理命令,可能多行END{}
处理完所有匹配数据后执行