免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 10633 | 回复: 2
打印 上一主题 下一主题

[文本处理] grep仅仅显示文件名 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-10-04 14:46 |只看该作者 |倒序浏览
grep  "正则"  /home/rsina/*
这个命令把含有“正则”两个字的文件,行,全部显示了,我现在只想要文件名显示出来,请问,如何操作?

论坛徽章:
3
IT运维版块每日发帖之星
日期:2015-12-30 06:20:00IT运维版块每日发帖之星
日期:2016-02-16 06:20:00每日论坛发贴之星
日期:2016-02-16 06:20:00
2 [报告]
发表于 2012-10-04 15:03 |只看该作者
  1. [root@localhost home]# cat intro
  2. The Unix operating system was pioneered by Ken
  3. Thompson and Dennis Ritchie at Bell Laboratories
  4. in the late 1960s.One of the primary goals in
  5. the design of the Unix system was to create an
  6. enbironment that promoted efficient program
  7. development.
  8. [root@localhost home]# grep -l "Unix" *
  9. intro
复制代码
try “grep --help” to find out the parameters that you want

论坛徽章:
15
2015年辞旧岁徽章
日期:2015-03-03 16:54:15双鱼座
日期:2015-01-15 17:29:44午马
日期:2015-01-06 17:06:51子鼠
日期:2014-11-24 10:11:13寅虎
日期:2014-08-18 07:10:55酉鸡
日期:2014-04-02 12:24:51双子座
日期:2014-04-02 12:19:44天秤座
日期:2014-03-17 11:43:36亥猪
日期:2014-03-13 08:13:51未羊
日期:2014-03-11 12:42:03白羊座
日期:2013-11-20 10:15:18CU大牛徽章
日期:2013-04-17 11:48:45
3 [报告]
发表于 2012-10-04 15:04 |只看该作者
用 -l  参数
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP