【问题标题】:How to find a file containing specific text in Centos7?如何在 Centos7 中查找包含特定文本的文件?
【发布时间】:2018-01-14 15:19:44
【问题描述】:

我有一个在 centos 7 上运行的服务器。我需要找到一个包含 0774386850 的文件,以便我可以用另一个字符串替换。请给我一个 Linux 命令来给我那个文件

【问题讨论】:

标签: linux centos7


【解决方案1】:

您可以使用 grep/fgrepfind 来实现您的目标。

【讨论】:

  • find /path/to/files -type f -exec sed -i 's/oldstring/new string/g' {} \;
【解决方案2】:

通过使用grep命令,可以达到你的预期

grep -rlnw '/path/to/somewhere/' -e '0774386850'
-r or -R is recursive,
-n is line number, and
-w stands for match the whole word.
-l (lower-case L) file name of matching files.

【讨论】:

    【解决方案3】:

    grep -r "0774386850 " /path/to/dir

    【讨论】:

      猜你喜欢
      • 2012-09-22
      • 1970-01-01
      • 2012-05-22
      • 1970-01-01
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 2017-04-21
      • 1970-01-01
      相关资源
      最近更新 更多