3.shellScript
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
# 普通变量
A=2
# 数组
a=(1 2 3 4 5)
echo ${a[0]}
echo ${a[-1]}
echo ${a[*]} 数组中所有元素
echo ${a[@]} 数组中所有元素
echo ${a[@]:0:3} 数组中1-3个元素
echo ${#a[@]} 数组中元素的个数
# 在curl中使用变量
url="www.example.com"
curl "$url"
set -x
file=file:///Users/xxx/temp/a
proto=file
curl --proto "=$proto" $fileif condition
then
command1
...
fiif condition
then
command1
else
command2
fiif condition
then
command1
elif condition2
then
command2
else
command3
fifor file in `ls /etc`sleep 1 # 睡眠1秒
sleep 1s # 睡眠1秒
sleep 1m # 睡眠1分
sleep 1h # 睡眠1小时