2016-07-28 27 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

如果找不到,我怎麼知道哪些對找不到 –