【问题标题】:Using grep to find string in two files?使用 grep 在两个文件中查找字符串?
【发布时间】:2014-04-30 09:56:49
【问题描述】:

我想在两个文本文件中查找特定字符串 - 我知道如何在单个文件中执行此操作,但是如何选择多个文件,下面的示例针对单个文本文件执行此操作,我想要搜索文件 myfile.txt 和 otherfile.txt

grep "redeem" /home/tom/myfile.txt

【问题讨论】:

  • 使用:grep 'pattern' file1 file2 file...
  • 哦,我知道会给你一个很好的镜头
  • @sat 如果你添加答案,我会接受,谢谢

标签: linux unix command-line terminal grep


【解决方案1】:

你可以这样做,

grep 'redeem' file1 file2 file3..

语法:

grep [OPTIONS] PATTERN [FILE...]

通常grep 可以在多个文件中进行pattern 匹配。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-19
    • 2012-04-17
    • 1970-01-01
    • 1970-01-01
    • 2013-10-20
    • 2020-02-18
    • 2014-10-29
    • 2013-07-06
    相关资源
    最近更新 更多