shell中的函数与数组
# cat fun3.sh #!/bin/baship()
{
ifconfig |grep -A1 "$1: "|awk '/inet/ {print $2}'
}
read -p "please input the eth name: " eth
ip $eth
# sh fun3.sh
please input the eth name: ens33
192.168.188.130
# sh fun3.sh
please input the eth name: ens33:0
192.168.188.150
# sh fun3.sh
please input the eth name: ens37
192.168.252.128
页:
[1]