wdx1992828 发表于 2018-8-19 06:38:37

shell中的函数与数组

# cat fun3.sh  #!/bin/bash
  ip()
  {
  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]
查看完整版本: shell中的函数与数组