Shell check IP
2024-10-22 08:16:35
#! /bin/bash
checkip() {
if echo $1 |egrep -q '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' ; then
a=`echo $1 | awk -F. '{print $1}'`
b=`echo $1 | awk -F. '{print $2}'`
c=`echo $1 | awk -F. '{print $3}'`
d=`echo $1 | awk -F. '{print $4}'`
for n in $a $b $c $d; do
if [ $n -ge 255 ] || [ $n -le 0 ]; then
echo 'bad ip(2)!'
return 2
fi
done
else
echo 'bad ip(1)!'
return 1
fi
}
echo -n "Please input the ip:"
read ip
checkip $ip
最新文章
- iOS/Android/Web Url Encode空格處理 原文連結:http://read01.com/3gDO.html
- C语言中的结构体,结构体数组
- UVA 10341 Solve It 二分
- UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)
- MVC跳转
- Morse Clock
- (Problem 73)Counting fractions in a range
- 关于DOMContentLoaded
- iOS 面试题、知识点 之一
- mybatis一级缓存二级缓存
- 北亚关于HP EVA4400/6400/8400/P6000的数据恢复解决方案
- Preload,Prefetch 和它们在 Chrome 之中的优先级
- django学习笔记-模板层
- mac 端口占用问题
- idea : shorten command line
- Java多线程编程模式实战指南(二):Immutable Object模式
- react-router 4.3 js实现跳转
- Linux服务器---邮件服务openwebmail配置
- mybatis源码阅读心得
- 使用 Spring 2.5 注释驱动的 IoC 功能