首页 > 其他 > 详细

awk用法

时间:2015-07-21 23:38:57      阅读:219      评论:0      收藏:0      [点我收藏+]

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 root@ubuntu-ceph-07:~# echo  "this is a test" >>test.txt
 2 root@ubuntu-ceph-07:~# awk {print $0} test.txt
 3 this is a test
 4 root@ubuntu-ceph-07:~# awk {print $1} test.txt
 5 this
 6 root@ubuntu-ceph-07:~# awk {print $2} test.txt
 7 is
 8 root@ubuntu-ceph-07:~# awk {print $1$2} test.txt
 9 thisis
10 root@ubuntu-ceph-07:~# awk BEGIN{OFS="#"}{print $1,$2} test.txt
11 this#is
12 root@ubuntu-ceph-07:~# awk {print $1,$2} test.txt
13 this is
14 root@ubuntu-ceph-07:~# awk BEGIN{OFS=":"}{print $1, $2, $3, $4} test.txt
15 this:is:a:test
16 root@ubuntu-ceph-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

awk用法

原文:http://www.cnblogs.com/chris-cp/p/4665795.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!