#!/bin/bash ##声明此脚本使用bash解释器运行,所有的命令都由它来解析
[ -z "$1" ] && { ##脚本名后未接参数时,输出以下信息
echo "Error:Please input interface following Script!!!"
exit
}
ifconfig $1 &> /dev/null || { ##脚本后所解参数,在执行此命令时,回传值不为0,输出以下信息
echo "$1 is not found!"
exit
}
#ifconfig $1 | head -n 2 | tail -n 1 | cut -d " " -f 10
ifconfig $1 | awk '/inet\>/ {print $2}' ##将ifconfig $1输出的信息中,有inet字段的行中的第二个字段打印输出,"inet\>" 表示inet字符之后不能有字符