user6438693
user6438693

Reputation:

How to remove all alphabets, numbers '@' and '.' from a file in bash?

I have a data of email id's and i want to check if email id's contain any special character other than '@' and '.' so i want to remove all the alphabets, numbers, '@' and '.'. I know to remove all digits we can use following command:

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

Sample Input:

[email protected]                                                  
[email protected]                                                        
hira#[email protected]                                                       
shop@lov$echarms.jp                                                              
[email protected]                                                

Sample Output:

-

#
$
-

Can anyone help me on this?

Upvotes: 1

Views: 526

Answers (1)

tso
tso

Reputation: 4904

with tr:

tr -d '[[:alnum:]].@' <filename

Upvotes: 2

Related Questions