shell过滤特定内容

时间:2014-12-08 15:46:20   收藏:0   阅读:235

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

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

#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


本文出自 “always_yunwei” 博客,请务必保留此出处http://alwaysyunwei.blog.51cto.com/3224143/1587555

评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!