Shell detects whether the IP entered is legitimate

Source: Internet
Author: User

Detects whether the IP entered is legitimate


#!/bin/bash


Read-p "Input An IP address:" Ip_addr

N1= ' echo $ip _addr|awk-f. ' {print $} '

N2= ' echo $ip _addr|awk-f. ' {print $} '

N3= ' echo $ip _addr|awk-f. ' {print $} '

N4= ' echo $ip _addr|awk-f. ' {print $4} '


If [$n 1-ge 1]&&[$n 1-lt 255]&&[$n 2-ge 1]&&[$n 2-lt 255]&&[$n 3-ge 1]&& [$n 3-lt 255]&&[$n 4-ge 1]&&[$n 4-lt 255]

Then

echo "Right IP."

Else

echo "Wrong IP."

Fi


This article is from the "10484588" blog, please be sure to keep this source http://10494588.blog.51cto.com/10484588/1725933

Shell detects whether the IP entered is legitimate

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.