#! /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

最新文章

  1. iOS/Android/Web Url Encode空格處理 原文連結:http://read01.com/3gDO.html
  2. C语言中的结构体,结构体数组
  3. UVA 10341 Solve It 二分
  4. UVaLive 7267 Mysterious Antiques in Sackler Museum (if-else,枚举)
  5. MVC跳转
  6. Morse Clock
  7. (Problem 73)Counting fractions in a range
  8. 关于DOMContentLoaded
  9. iOS 面试题、知识点 之一
  10. mybatis一级缓存二级缓存
  11. 北亚关于HP EVA4400/6400/8400/P6000的数据恢复解决方案
  12. Preload,Prefetch 和它们在 Chrome 之中的优先级
  13. django学习笔记-模板层
  14. mac 端口占用问题
  15. idea : shorten command line
  16. Java多线程编程模式实战指南(二):Immutable Object模式
  17. react-router 4.3 js实现跳转
  18. Linux服务器---邮件服务openwebmail配置
  19. mybatis源码阅读心得
  20. 使用 Spring 2.5 注释驱动的 IoC 功能

热门文章

  1. 20170517 ABAP debug
  2. linux wdcp安装
  3. C# 面向对象三大特性:封装、继承、多态
  4. C#中字符串的内存分配与驻留池
  5. PictureBox 双缓冲防止闪屏
  6. dockfile
  7. ZOJ 3958 Cooking Competition 【水】
  8. Archimate
  9. complexHeatmap包画分类热图
  10. Android 下的usb框架及功能点【转】