G0dspeed's Blog

Stay Hungary, Stay Foolish
  1. 首页
  2. 经验技巧
  3. 正文

怎样在Linux下搜索包含特定字串的文件

2022/08/05 437点热度 0人点赞 0条评论

发现这个功能非常有用,必须收藏起来。

grep -rnw '/path/to/somewhere/' -e 'pattern'

  • -r or -R is recursive,
  • -n is line number, and
  • -w stands for match the whole word.
  • -l (lower-case L) can be added to just give the file name of matching files.
  • -e is the pattern used during the search

或者

grep -Ril "text-to-find-here" /

  • i stands for ignore case (optional in your case).
  • R stands for recursive.
  • l stands for "show the file name, not the result itself".
  • / stands for starting at the root of your machine.

标签: Linux
最后更新:2022/08/05

G0dspeed

这个人很懒,什么都没留下

点赞
< 上一篇

文章评论

取消回复

Time limit is exhausted. Please reload CAPTCHA.

COPYRIGHT © 2022 G0dspeed's Blog. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang