grep:文本过滤器,
grep "pattern" input_file ....
sed: 流编辑器;
sed "command/PATTERD/"
awk:报告生成器。能够将输入的信息格式化之后显示;包括nawk版本,gawk版本
用法:
awk [option] ‘script‘ file1 file2, ...
awk [option] ‘PATTERN {action}‘ file1, file2. ...
print, printf
1 [email protected]07:~# echo "this is a test" >>test.txt 2 [email protected]07:~# awk ‘{print $0}‘ test.txt 3 this is a test 4 [email protected]07:~# awk ‘{print $1}‘ test.txt 5 this 6 [email protected]07:~# awk ‘{print $2}‘ test.txt 7 is 8 [email protected]07:~# awk ‘{print $1$2}‘ test.txt 9 thisis 10 [email protected]07:~# awk ‘BEGIN{OFS="#"}{print $1,$2}‘ test.txt 11 this#is 12 [email protected]07:~# awk ‘{print $1,$2}‘ test.txt 13 this is 14 [email protected]07:~# awk ‘BEGIN{OFS=":"}{print $1, $2, $3, $4}‘ test.txt 15 this:is:a:test 16 [email protected]07:~# awk ‘BEGIN{OFS=":"}{print $1, $2, "AAAAAAA",$3, $4}‘ test.txt 17 this:is:AAAAAAA:a:test
地址:http://edu.51cto.com/lesson/id-17373.html
时间: 2024-10-23 05:26:08