前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >grep经常使用使用方法「建议收藏」

grep经常使用使用方法「建议收藏」

作者头像
全栈程序员站长
发布2022-07-10 14:44:23
2750
发布2022-07-10 14:44:23
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是全栈君。

grep简单介绍

正如linux的man文件里所描写叙述的那样:

grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints the matching lines. In addition, two variant programs egrep and fgrep are available. egrep is the same as grep -E. fgrep is the same as grep -F. Direct invocation as either egrep or fgrep is deprecated, but is provided to allow historical applications that rely on them to run unmodified.

grep是用来在一个文件里查找和给定的模式相匹配的行的命令,同一时候egrep 和 fgrep都已经被弃用。取而代之的是 grep -E和grep -F。

用法

在单个文件里搜索包括字符串的行

语法: grep “literal_string” filename

在多个文件里搜索包括字符串的行

语法: grep “this” demo_* 注:这个的搜索域是demo_为前缀的文件

使用 -i 參数能够实现大写和小写无关

能够使用正則表達式来过滤

语法: grep “REGEX” filename

详细用法能够參考:http://www.cnblogs.com/kuyuecs/archive/2012/07/13/2589988.html 写得非常不错的博客。

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/115378.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年2月5,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • grep简单介绍
    • 用法
      • 在单个文件里搜索包括字符串的行
      • 在多个文件里搜索包括字符串的行
      • 使用 -i 參数能够实现大写和小写无关
      • 能够使用正則表達式来过滤
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档