2017-10-11 115 views
2

我有一個電子郵件ID的數據,我想檢查電子郵件ID是否包含'@'和'。'以外的任何特殊字符。所以我想刪除所有的字母,數字,'@'和'。'。我知道要刪除所有的數字,我們可以使用下面的命令:如何刪除所有字母,數字'@'和'。'從bash中的文件?

sed 's/[0-9]*//g' input.txt > output.txt 

樣品輸入:

[email protected]             
[email protected]               
hira#[email protected]              
[email protected]$echarms.jp                
[email protected]             

樣本輸出:

- 

# 
$ 
- 

誰能幫助我在這?

+0

也許[在文件中刪除特殊字符(http://www.unix.com/shell-programming-and-scripting/24065-removing-special-characters-file。 HTML)可以幫助你 – Frank

+0

我想查看那裏有什麼特殊字符,怎麼可能將它們刪除幫助我 –

回答

3

與TR:

tr -d '[[:alnum:]][email protected]' <filename 
+0

謝謝!它的工作,如果我想要刪除所有的' - '和'+'呢? –

+0

只需加引號''[[:alnum:]]。@ + - '' – tso

相關問題