Awk Cygwin-grep(如果文件包含)

Awk Cygwin-grep(如果文件包含),awk,grep,gawk,Awk,Grep,Gawk,好的,基本上我有一个电子邮件列表 EMAILS.TXT 然后我有另一堆.txt文件,包含email:phonenumber:name Compiled1.txt Compiled2.txt Compiled3.txt ... 我可以使用grep或gawk搜索包含compiled1、compiled2的文件夹,以查看行中是否包含.txt文件中的电子邮件吗 以身作则 email.txt Contains " example@example.com " & " example1@examp

好的,基本上我有一个电子邮件列表

EMAILS.TXT
然后我有另一堆.txt文件,包含email:phonenumber:name

Compiled1.txt
Compiled2.txt
Compiled3.txt
...
我可以使用grep或gawk搜索包含compiled1、compiled2的文件夹,以查看行中是否包含.txt文件中的电子邮件吗

以身作则

email.txt Contains " example@example.com " & " example1@example1.com "
包含

Compiled1.txt & Compiled2.txt have both these lines
Cygwin/Gnuwin从compiled1和compiled2输出行,如果它包含从emails.txt指定的行

Output > example@example.com:000000:ExampleUser 
         example1@example1.com:00010101:ExampleUser2
         ...
你可以用

grep -Fi -f EMAILS.TXT Compiled*.txt
-f EMAILS.TXT
使用
EMAILS.TXT
行作为搜索模式。
-F
禁用符号的特殊处理,如

-i
不区分大小写的搜索

输出的格式为

File-in-which-a-match-was-found:Matched-line-from-that-file
以您的例子为例:

Compiled1.txt:example@example.com:000000:ExampleUser
Compiled1.txt:example1@example1.com:00010101:ExampleUser2
Compiled2.txt:example@example.com:000000:ExampleUser
Compiled2.txt:example1@example1.com:00010101:ExampleUser2
如果您也对行号感兴趣,请将
-n
添加到命令中