#!/bin/bash #date: 2016.03.20 #The script for display ipaddress. #Author:xusjclo read -p "please input the device": name case $name in eth0) IP=`ifconfig |grep -A1 $name |grep -v Link | awk '{print $2}' |cut -d : -f 2` echo "The $name's ip address is $IP" ;; eth1) IP=`ifconfig |grep -A1 $name |grep -v Link |awk '{print $2}' | cut -d : -f 2` echo "The $name's ip address is $IP" ;; eth2) IP=`ifconfig |grep -A1 $name |grep -v Link |awk '{print $2}' | cut -d : -f 2` echo "The $name's ip address is $IP" ;; eth3) IP=`ifconfig |grep -A1 $name |grep -v Link |awk '{print $2}' | cut -d : -f 2` echo "The $name's ip address is $IP" ;; eth4) IP=`ifconfig |grep -A1 $name |grep -v Link |awk '{print $2}' | cut -d : -f 2` echo "The $name's ip address is $IP" ;; *) echo "Usage eth0|eth1|eth2|eth3|em1|em2|em3|em4" esac
shell获取Linux服务器I
原创
©著作权归作者所有:来自51CTO博客作者ciscoxushaojie的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
阿里云云服务器-安全计算环境(linux服务器)整改
安全计算环境(linux服务器)
服务器 阿里云服务器 缓存