#!/bin/bash
# 循环
for loop in 1 2 3 4 5
do
echo "The value is: $loop"
done
# 数组
services=(serviceA serviceB serviceC serviceD)
echo ${service}
# [@]表示数组里所有元素
for service in ${services[@]}
do
echo ${service}
echo $service
done
# 判断 数字相等 -eq
# ${1}表示执行shell脚本时的第一个参数,${0}表示脚本本身的名称
if [[ ${1} -eq 2 ]]; then
#statements
echo "param value is 2"
else
echo "param value is other"
fi
# 判断字符串相等
if [[ ${1} == "str" ]]; then
#statements
echo "parm value is string 'str'"
else
echo "parm value is string 'other character'"
fi
参考:
http://c.biancheng.net/view/1262.html
https://blog.csdn.net/zhan570556752/article/details/80399154