2016-10-18 20 views
0

好了,所以基本上我有一個文件,方含電子郵件&另外100個文件方含IP電話電子郵件的grep/Gawk的 - 如果行包含添加到found.txt

那麼什麼想知道的,如果有可能,以檢查是否從線包含100個.txt文件的文件夾包含[email protected]

例如find.txt的,

[email protected] 
    [email protected] 
    [email protected] 

等.. 100txtfiles

0.0.0.0  002921931  [email protected] 
    123.0.0.1 00029382 [email protected] 

等等

例子..

所以,我要的是如果100txtfiles行包含來自find.txt的電子郵件,則輸出到found.txt

+0

你有什麼試過?你想要找到.txt文件是什麼?整條線? – Tensibai

回答

0

此行應爲你工作:

grep -Ff find.txt /dir/to/100.txt/*.txt > found.txt 

如果你只是想要的文件名稱,添加-l選項:

grep -Flf find.txt ..... 

試試看。

0

在awk中:

$ awk 'NR==FNR{a[$1];next} ($3 in a)' find.txt path_to_100_files/* 
    0.0.0.0  002921931  [email protected] 

最終要輸出到found.txt與上面的命令後> found.txt重定向。輸出就是這樣,因爲你沒有在你的問題中包含預期的輸出。

相關問題