免费注册 查看新帖 |

Chinaunix

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

awk 和 grep -E (RHEL 5.4 ) 匹配结果为什么不一样 [复制链接]

论坛徽章:
0
发表于 2012-04-26 14:39 |显示全部楼层
  1. [root@localhost ~]# awk --version
  2. GNU Awk 3.1.5
  3. ......
  4. [root@localhost ~]# grep -E "(.+=.+,){1,}" map
  5. WebSphere:cell=localhostNode01Cell,node=localhostNode01,server=server1
  6. [root@localhost ~]# awk '$0~/(.+=.+,){1,}/' map
  7. [root@localhost ~]# cat map
  8. ......
  9. WebSphere:cell=localhostNode01Cell,node=localhostNode01,server=server1
  10. ......
复制代码
同样的表达式为什么结果不一样呢

论坛徽章:
0
发表于 2012-04-26 14:42 |显示全部楼层
是平台的问题吗,印象中以前用的系统没这样的

论坛徽章:
0
发表于 2012-04-26 14:51 |显示全部楼层
大家的机器上没这种问题吗?

论坛徽章:
0
发表于 2012-04-26 15:06 |显示全部楼层
本帖最后由 jils2013 于 2012-04-26 15:07 编辑

结贴,太蛋疼了,rhel  上居然需要加 --posix 或者 --re-interval

下面是man里的描述

       r{n}
       r{n,}
       r{n,m}     One  or  two  numbers inside braces denote an interval expression.  If there is one number in the
                      braces, the preceding regular expression r is repeated n times.  If there are two  numbers  sepa-
                      rated by a comma, r is repeated n to m times.  If there is one number followed by a comma, then r
                      is repeated at least n times.
                      Interval expressions are only available if either --posix or --re-interval is  specified  on  the
                      command line.

论坛徽章:
3
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:51:162015年亚洲杯之阿曼
日期:2015-04-07 20:00:59
发表于 2012-04-26 15:17 |显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
13
15-16赛季CBA联赛之同曦
日期:2016-01-28 19:52:032015亚冠之北京国安
日期:2015-10-07 14:28:19NBA常规赛纪念章
日期:2015-05-04 22:32:03处女座
日期:2015-01-15 19:45:44卯兔
日期:2014-10-28 16:17:14白羊座
日期:2014-05-24 15:10:46寅虎
日期:2014-05-10 09:50:35白羊座
日期:2014-03-12 20:52:17午马
日期:2014-03-01 08:37:27射手座
日期:2014-02-19 19:26:54子鼠
日期:2013-11-30 09:03:56狮子座
日期:2013-09-08 08:37:52
发表于 2012-04-26 15:36 |显示全部楼层
zooyo 发表于 2012-04-26 15:17
因为awk不认识{n,m}这样的正则表达式.


原来是这样!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP