Linux之awk 练习题--(只包含练习题)
答案见: https://www.cnblogs.com/joyware/p/16645516.html
1.在/etc/shadow文件中,如果第二字段为!!则输出该行,如果为*则输出第一字段,都不是则输出第五字段。
2.获取本机eth0网卡IP.
3. 在/etc/passwd 中,打印获取到的UID小于100的值?
4.过滤掉下面文本konge.txt空行。
[root@localhost home]# cat konge.txt AAA BBB CCC DDD [root@localhost home]#
5.1统计日志文件xxx.log每个shopId出现的错误的次数.
5.2统计日志文件xxx.log每个shopId出现的错误的次数.
[root@ecs-76840553 home]# cat xxx.log 00:09:07.655 [showcase_backend][ShowcaseServiceImpl] WARN - showcase add recommend from taobao failed |shopId=1482502318|itemId=548320850657||530|Remote service error|isv.item-recommend-service-error:SAVE_REQUEST_TOO_MANY_TIMES| 00:09:07.673 [showcase_backend][topsdk] ERROR - 2017-06-27 00:09:07.673^_^xxxxxxx^_^taobao.item.recommend.add^_^10.28.42.60^_^Linux^_^18^_^http://gwx.api.taobao.com/router/rest^_^app_key=xxxxx&partner_id=top-sdk-java-20170607&method=taobao.item.recommend.add&v=2.0&session=xxxxxxxx&format=json&sign_method=hmac&num_iid=5483473847602×tamp=2017-06-27+00%3A09%3A07^_^{"error_response":{"code":530,"msg":"Remote service error","sub_code":"isv.item-recommend-service-error:SAVE_REQUEST_TOO_MANY_TIMES","sub_msg":"橱窗推荐商品失败","request_id":"qm4l3wu2cnhu"}} 00:09:07.673 [showcase_backend][ShowcaseServiceImpl] WARN - showcase add recommend from taobao failed |shopId=14825032138|itemId=548347847602||530|Remote service error|isv.item-recommend-service-error:SAVE_REQUEST_TOO_MANY_TIMES| 00:09:07.695 [showcase_backend][ShowcaseServiceImpl] WARN - showcase add recommend from taobao failed |shopId=148250232138|itemId=546199835284||530|Remote service error|isv.item-recommend-service-error:SAVE_REQUEST_TOO_MANY_TIMES|橱
6. 每个在 start与end块内,查询第一次出现的 i hate you 行
[root@ecs-76840553 myawk]# cat 1.txt hate you 1 start 1 i love you i hate you 2 i hate you3 end 1 start 2 i love you i hate you 22 i hate you 4 end 2 start 2 i love you i hate you 33 i hate you 4 end 2 start 2 i love you i hate you 44 i hate you 4 end 2 [root@ecs-76840553 myawk]#
7.找出含有2的行。
[root@ecs-76840553 myawk]# cat 2.txt 111 121 333 234 444 552 234 555 626 [root@ecs-76840553 myawk]#
8.统计机器中网络连接各个状态个数. netstat -a (tcp)
9.如何使用awk查询指定的字符。
10.10.49.100 10.10.49.101 10.10.49.100 10.10.49.102 10.10.49.101 10.12.49.100