免费注册 查看新帖 |

Chinaunix

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

[文本处理] 关于grep -o与^的疑问 [复制链接]

论坛徽章:
0
发表于 2017-09-01 09:31 |显示全部楼层
echo '1234' | grep -o '^.'
1
2
3
4
为什么不是只输出1呢?求大神帮忙解答

论坛徽章:
39
辰龙
日期:2013-08-21 15:45:192015亚冠之广州富力
日期:2015-05-12 16:34:52亥猪
日期:2015-03-03 17:22:00申猴
日期:2015-03-03 17:21:37未羊
日期:2014-10-10 13:45:41戌狗
日期:2014-06-17 09:53:29巨蟹座
日期:2014-06-12 23:17:17双鱼座
日期:2014-06-10 12:42:44寅虎
日期:2014-06-09 12:52:172015亚冠之卡尔希纳萨夫
日期:2015-05-24 15:24:35黄金圣斗士
日期:2015-12-02 17:25:0815-16赛季CBA联赛之吉林
日期:2017-06-24 16:43:52
发表于 2017-09-01 09:55 |显示全部楼层
  1. [root@DC-202 ~]# grep --version
  2. grep (GNU grep) 2.20
  3. Copyright (C) 2014 Free Software Foundation, Inc.
  4. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
  5. This is free software: you are free to change and redistribute it.
  6. There is NO WARRANTY, to the extent permitted by law.

  7. Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
  8. [root@DC-202 ~]# lsb_release -a
  9. LSB Version:        :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
  10. Distributor ID:        CentOS
  11. Description:        CentOS release 6.8 (Final)
  12. Release:        6.8
  13. Codename:        Final
  14. [root@DC-202 ~]# echo '1234' |grep -o '^.'
  15. 1
  16. [root@DC-202 ~]# echo 1234 |grep -o '^.'
  17. 1
  18. [root@DC-202 ~]#
复制代码

论坛徽章:
0
发表于 2017-09-01 10:12 |显示全部楼层
回复 2# 关阴月飞

grep 2.5.1
rhel 5.8
难道是grep版本的问题?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP