Shell正则表达式验证IP地址
本机多个IP
ifconfig | awk '/inet/{print $2}' | awk -F: '{print $2}'
首先,先用这个来着
CheckIPAddress() { echo $1 > /tmp/tmpserverip echo $1 |grep "^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$" > /dev/null if [ $? = 1 ]; then return 1 else a=$(cut -d. -f1 /tmp/tmpserverip) b=$(cut -d. -f2 /tmp/tmpserverip) c=$(cut -d. -f3 /tmp/tmpserverip) d=$(cut -d. -f4 /tmp/tmpserverip) for loop in $a $b $c $d do if [ $loop -ge 255 ] || [ $loop -le 0 ]; then return 2 fi done fi return 0 }
最初的时候,参考过下面的这些
grep "^([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5]).([01]?dd?|2[0-4]d|25[0-5]).$"
输入ip,检查其是否满足的ip书写规范,即不能大于255,不能有字母,和其他标点,参考网上的,自己搞了个如下,做个标记!@
echo -n 'Enter the Server-ip:' read BISSip echo $BISSip > /tmp/tmpserverip echo $BISSip|grep "^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$" > /dev/null num=$? if [ $num = 1 ] then echo error ip,please enter correct else { a=$(cut -d. -f1 /tmp/tmpserverip) b=$(cut -d. -f2 /tmp/tmpserverip) c=$(cut -d. -f3 /tmp/tmpserverip) d=$(cut -d. -f4 /tmp/tmpserverip) { if [ $a -ge 255 ]||[ $a -le 0 ] then echo a:error ip else echo 1 > /tmp/jack fi } { if [ $b -ge 255 ]||[ $b -lt 0 ] then echo b:error ip else echo 1 >>/tmp/jack fi } { if [ $c -ge 255 ]||[ $c -lt 0 ] then echo c:error ip else echo 1 >>/tmp/jack fi } { if [ $d -ge 255 ]||[ $d -le 0 ] then echo d:error ip else echo 1 >> /tmp/jack fi }
Centos下查看网卡的实时流量命令
可以通过iptraf命令查看网卡的实时流量,图像非常直观。今天在测试服务器上准备看下网络流量[root@localhost~]#iptraf-deth0-bash:iptraf:commandnotfound发现运维同
linux下使用rinetd来实现端口转发
windows下的端口转发一般用的是自带的nat和porttunnel、portmaplinux下端口转发映射的程序叫rinetd,启动方法rinetd-c/etc/rinetd.conf,pkillrinetd关闭进程工具主页:htt
linux下通过命令行获取gmail的新邮件
linux下通过命令行获取gmail的新邮件,不需输入@gmail.com部分#!/bin/bashnum="33[1;36m"end="33[0m"read-p"Enteryourmail:"nameread-p"Enterpassofmail:"passatom=`wget-qO-https://$name:$
编辑:广州鸿名健康科技有限公司
标签:端口,命令行,网卡,实时,的是