我有这个文件名 emaillist.txt:
[email protected]
[email protected]
Ilias Magkakos [email protected]
Nick Pipshow [email protected]
Don Quixote [email protected]
Crazy Priest [email protected]
Fishroe Salad [email protected]
TaPanta Ola [email protected]
Laertis George [email protected]
Thiseas Sparrow [email protected]
Black Dreamer [email protected]
Callme Daddy [email protected]
Aggeliki Lykolouli [email protected]
Kompinadoros Yannnnis [email protected]
Serafino Titamola [email protected]
Joe Hard [email protected]
Bond James [email protected]
Endof Text [email protected]
我想只保留文件中的电子邮件并删除所有名字和姓氏。
答案1
在这里,由于电子邮件地址似乎始终是每行的最后一个空格分隔字段,因此您可以这样做:
awk '{print $NF}' < emaillist.txt
或者,如果电子邮件地址后面没有任何空格,请删除每行直到最后一个空格的所有内容:
sed 's/.*[[:space:]]//' < emaillist.txt
要检索所有至少包含一个@
字符的以空格分隔的单词,可以是(使用 GNUgrep
或兼容):
grep -o '[^[:space:]]*@[^[:space:]]*' < emaillist.txt