【问题标题】:How to grep file by another file's line using bash如何使用 bash 通过另一个文件的行 grep 文件
【发布时间】:2016-07-28 09:16:11
【问题描述】:

file1存储语句要grep,这里是file1的内容

.|||anymore .
,|||arguments
,|||atheists
,|||be
,|||because the
.|||because the

问题是它在某些句子中包含空格,而目标file2也包含空格,如何搜索所有file2内容以知道file2是否在file1中有这些句子 p>

如果找到它输出grep结果到另一个文件(附加),如果没有找到输出一个文件来保存它

【问题讨论】:

  • 显示两个文件中的示例数据以及您的预期输出

标签: bash


【解决方案1】:

试试这个-

while IFS= read -r i; do      #Reading the file line by line and saving lines in $i.
grep "$i" file2 >> output     #Grepping the line in the second file and outputting.
done < file1

您的问题需要进行编辑以提供更多详细信息。

【讨论】:

  • 如果找不到,我怎么知道什么对找不到
猜你喜欢
  • 1970-01-01
  • 2014-08-23
  • 2017-06-15
  • 1970-01-01
  • 2015-05-04
  • 2020-05-24
  • 2019-11-28
  • 1970-01-01
  • 2011-04-07
相关资源
最近更新 更多