过滤文件内电子邮箱和网站地址

过滤邮箱(只显示过滤文本):

#egrep -o '[A-Za-z0-9.]+@[A-Za-z0-9.]+\.[a-zA-Z]{2,3}' file.txt

zhangsan@sina.com

lishi.123@sohu.com


过滤网站地址:

#egrep -o 'http://[A-Za-z0-9\-\.]+\.[a-zA-Z]{2,3}' file.txt

http://code.nagios.google.com

http://www.baidu.com


过滤IP地址:

egrep -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" file.txt