免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1845 | 回复: 6

[文本处理] awk查找中文 [复制链接]

论坛徽章:
3
15-16赛季CBA联赛之八一
日期:2017-12-29 13:06:2315-16赛季CBA联赛之天津
日期:2018-08-08 17:39:4619周年集字徽章-年
日期:2019-12-25 22:50:31
发表于 2018-04-18 13:59 |显示全部楼层
本帖最后由 aaaa_123 于 2018-04-18 14:41 编辑

Hi...

cat a
  1days, 15:46:10,  Send OFFER with
  1days, 15:36:24,  Send 腾讯? with
  1days, 15:37:49,  Send 百度0 with
  1days, 15:43:23,  /京东 OFFER with
  1days, 15:44:16,  Send 啊里 with
  15:36:24,  Send 腾讯? with
  15:37:49,  Send 百度0 with
  15:43:23,  /京东 OFFER with
  15:44:16,  Send 啊里 with
  1days, 15:46:10,  Send OFFER with
  1days, 15:46:43,  Send OFFER with
  1days, 16:15:32, REQUEST  c7000ef3 is not in the address pool

忘了说明有这种现像  加多一行
  1days, 16:15:32, 控股  c7000ef3 is not in the address pool


当查找到含有啊里字符串的行时 空出一行

打印出
  1days, 15:36:24,  Send 腾讯? with
  1days, 15:37:49,  Send 百度0 with
  1days, 15:43:23,  /京东 OFFER with
  1days, 15:44:16,  Send 啊里 with

  15:36:24,  Send 腾讯? with
  15:37:49,  Send 百度0 with
  15:43:23,  /京东 OFFER with
  15:44:16,  Send 啊里 with



awk好像匹配中文字符串没反应  希望这里老大能纠正一下  thans
awk '/腾讯/{print}' file
要查找关键字
awk '/腾讯/百度/京东/啊里/\n{print}' file






论坛徽章:
145
技术图书徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11狮子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龙
日期:2014-01-08 15:26:12技术图书徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
发表于 2018-04-18 14:18 |显示全部楼层
回复 1# aaaa_123

$ awk '/[^\x00-\x7f]/' a
  1days, 15:36:24,  Send 腾讯? with
  1days, 15:37:49,  Send 百度0 with
  1days, 15:43:23,  /京东 OFFER with
  1days, 15:44:16,  Send 啊里 with
  15:36:24,  Send 腾讯? with
  15:37:49,  Send 百度0 with
  15:43:23,  /京东 OFFER with
  15:44:16,  Send 啊里 with

$ awk '/[^\x00-\x7f]/{print}/啊里/{print""}' a
  1days, 15:36:24,  Send 腾讯? with
  1days, 15:37:49,  Send 百度0 with
  1days, 15:43:23,  /京东 OFFER with
  1days, 15:44:16,  Send 啊里 with

  15:36:24,  Send 腾讯? with
  15:37:49,  Send 百度0 with
  15:43:23,  /京东 OFFER with
  15:44:16,  Send 啊里 with

$ awk '/[^\x00-\x7f]/{print}/腾讯|百度|京东|啊里/{print""}' a
  1days, 15:36:24,  Send 腾讯? with

  1days, 15:37:49,  Send 百度0 with

  1days, 15:43:23,  /京东 OFFER with

  1days, 15:44:16,  Send 啊里 with

  15:36:24,  Send 腾讯? with

  15:37:49,  Send 百度0 with

  15:43:23,  /京东 OFFER with

  15:44:16,  Send 啊里 with


论坛徽章:
3
15-16赛季CBA联赛之八一
日期:2017-12-29 13:06:2315-16赛季CBA联赛之天津
日期:2018-08-08 17:39:4619周年集字徽章-年
日期:2019-12-25 22:50:31
发表于 2018-04-18 14:31 |显示全部楼层
本帖最后由 aaaa_123 于 2018-04-18 14:34 编辑

  1days, 16:15:32, 控股  c7000ef3 is not in the address pool
忘了说明有这种现像
只打印出有关键字行,,没有匹配到的不要
腾讯/百度/京东/啊里/

论坛徽章:
3
15-16赛季CBA联赛之八一
日期:2017-12-29 13:06:2315-16赛季CBA联赛之天津
日期:2018-08-08 17:39:4619周年集字徽章-年
日期:2019-12-25 22:50:31
发表于 2018-04-18 14:39 |显示全部楼层
回复 2# jason680

  1days, 16:15:32, 控股  c7000ef3 is not in the address pool
老大   忘了说明有这种现像

论坛徽章:
25
程序设计版块每日发帖之星
日期:2016-05-03 06:20:0015-16赛季CBA联赛之八一
日期:2018-07-05 10:34:09黑曼巴
日期:2018-07-06 15:19:5015-16赛季CBA联赛之佛山
日期:2018-08-03 13:19:3315-16赛季CBA联赛之山西
日期:2018-08-07 19:46:2315-16赛季CBA联赛之广夏
日期:2018-08-08 19:31:5015-16赛季CBA联赛之青岛
日期:2018-11-26 15:21:5015-16赛季CBA联赛之上海
日期:2018-12-11 09:45:3219周年集字徽章-年
日期:2020-04-18 23:54:5215-16赛季CBA联赛之深圳
日期:2020-04-19 21:40:19黑曼巴
日期:2022-04-03 17:55:1315-16赛季CBA联赛之八一
日期:2018-07-03 16:56:46
发表于 2018-04-18 15:26 |显示全部楼层
本帖最后由 wh7211 于 2018-04-18 15:29 编辑

回复 1# aaaa_123


  1. cat a
  2.   1days, 15:46:10,  Send OFFER with
  3.   1days, 15:36:24,  Send 腾讯? with
  4.   1days, 15:37:49,  Send 百度0 with
  5.   1days, 15:43:23,  /京东 OFFER with
  6.   1days, 15:44:16,  Send 啊里 with
  7.   15:36:24,  Send 腾讯? with
  8.   15:37:49,  Send 百度0 with
  9.   15:43:23,  /京东 OFFER with
  10.   15:44:16,  Send 啊里 with
  11.   1days, 15:46:10,  Send OFFER with
  12.   1days, 15:46:43,  Send OFFER with
  13.   1days, 16:15:32, REQUEST  c7000ef3 is not in the address pool

  14. 忘了说明有这种现像  加多一行
  15.   1days, 16:15:32, 控股  c7000ef3 is not in the address pool

  16. awk '/腾讯|百度|京东|啊里/;/啊里/{print ""}' a
  17.   1days, 15:36:24,  Send 腾讯? with
  18.   1days, 15:37:49,  Send 百度0 with
  19.   1days, 15:43:23,  /京东 OFFER with
  20.   1days, 15:44:16,  Send 啊里 with

  21.   15:36:24,  Send 腾讯? with
  22.   15:37:49,  Send 百度0 with
  23.   15:43:23,  /京东 OFFER with
  24.   15:44:16,  Send 啊里 with
复制代码

论坛徽章:
3
15-16赛季CBA联赛之八一
日期:2017-12-29 13:06:2315-16赛季CBA联赛之天津
日期:2018-08-08 17:39:4619周年集字徽章-年
日期:2019-12-25 22:50:31
发表于 2018-04-18 15:36 |显示全部楼层
thans  学习了

论坛徽章:
0
发表于 2018-04-19 21:52 |显示全部楼层
赞!!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP