【发布时间】:2018-06-16 08:50:05
【问题描述】:
我正在使用
代码-
grep -Ff list.txt C:/data/*.txt > found.txt
但它一直输出无效响应,行不包含我输入的电子邮件..
list.txt 包含 -
email@email.com
customer@email.com
imadmin@gmail.com
newcustomer@email.com
helloworld@yes.com
等等.. 每行匹配的电子邮件,
搜索文件包含 -
user1:phonenumber1:email@email.com:last-active:recent
user2:phonennumber2:customer@email.com:last-active:inactive
user3:phonenumber3:blablarandom@bla.com:last-active:never
那么另一个可能包含 -
blublublu email@email.com phonenumber subscribed
nanananana customer@email.com phonenumber unsubscribed
useruser noemailinput@noemail.com phonenumber pending
所以我要做的是向 grep 提供电子邮件列表/字符串列表“list.txt”,然后搜索提供的目录以查找每个字符串的匹配项,并输出包含每个匹配项的整行。
这种情况下的输出示例是 -
user1:phonenumber1:email@email.com:last-active:recent
user2:phonennumber2:customer@email.com:last-active:inactive
blublublu email@email.com phonenumber subscribed
nanananana customer@email.com phonenumber unsubscribed
但它不会输出其他两行 -
user3:phonenumber3:blablarandom@bla.com:last-active:never
useruser noemailinput@noemail.com phonenumber pending
因为该行内没有字符串。
【问题讨论】:
-
我将内容复制到文件并运行命令。它没有输出 user3 和 noemailinput。
-
@Cyrus 解决方案不起作用,它似乎对我不起作用:S
-
@choroba 尝试使用特殊字符“-、_、.”或类似字符的电子邮件,也许这就是导致我的问题的原因?
-
我建议
dos2unix s.txt删除 DOS 换行符。
标签: bash awk grep gawk gnuwin32