码迷,mamicode.com
首页 > 系统相关 > 详细

过滤A类、B类、C类地址_shell脚本

时间:2016-08-10 23:01:31      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:shell

#!/bin/bash
#过滤A类、B类、C类地址
#过滤A类地址 -o 只显示符合的A类地址[1-126]
read -p "input the file absolute path:" file
egrep -o "([0-9]|[1-9][0-9]|1[01][0-9]|12[0-6])\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\>" $file |sort -n|uniq -c|sort -k 2 -rn >A_ip
#过滤B类地址【128-191】
egrep -o "(12[89]|1[3-8][0-9]|19[01])\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\>" $file |sort -n|uniq -c|sort -k 2 -rn >B_ip
#过滤C类地址【192-223】
egrep -o "(19[2-9]|2[0-1][0-9]|22[0-3])\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\>" $file |sort -n|uniq -c|sort -k 2 -rn >C_ip

本文出自 “天晴了要下雨” 博客,请务必保留此出处http://8776055.blog.51cto.com/8766055/1836645

过滤A类、B类、C类地址_shell脚本

标签:shell

原文地址:http://8776055.blog.51cto.com/8766055/1836645

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!