2016-07-28 22 views
0

的文件1店句到grep另一个文件的行文件要到grep,这里的内容文件1如何使用bash

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

的问题是它包含一些句子空间,和file2包含目标我怎样才能搜索所有的file2内容,以知道file2是否有这些在file1中的句子

如果发现它输出grep结果到另一个文件(追加),如果没有找到输出文件保留它

+1

显示来自这两个文件的样本数据与您的预期输出 – anubhava

回答

2

试试这个吧 -

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 

虽然你的问题需要编辑,以提供更多的细节。

+0

如果找不到,我怎么知道哪些对找不到 –