20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析

20.16/20.17 shell中的函数
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
显示变量的隐函数
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
执行的结果
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
参数只有一个1,执行的结果 第一个是1,第二个是空的,第三个也是空的,肢本的名字是fun1.sh,总共有1个参数
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
加法的函数
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
显示IP的隐函数
-A1是显示关键词的一行包括下一行
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
精准查找到IP
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
脚本就可以这样写,ip $eth 是输入一个网卡的名字
#!/bin/bash
ip()
{
ifconfig |grep -A1 "ens33: " |awk '/inet/ {print $2}'
}
read -p "Please input the eth name: " eth
ip $eth
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
执行结果
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
当输入ens37没有值,这时候就需要判断了,有2个判断,一个是输入的网卡是不是系统里的网上,别一个是,当输入的网上没有值
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.18 shell中的数组
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
查看数组的某一个值
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
可以更改元素的值
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析
20.16/20.17 shell中的函数20.18 shell中的数组20.19 告警系统需求分析

转载于:https://blog.51cto.com/13450039/2105988