shell 脚本写法:

* if else 写法

#!/bin/bash

# 定义变量
number=10

# 使用 if-elif-else 判断
if [ $number -eq 10 ]; then
    echo "Number is 10"
elif [ $number -eq 20 ]; then
    echo "Number is 20"
elif [ $number -eq 30 ]; then
    echo "Number is 30"
else
    echo "Number is neither 10, 20 nor 30"
fi

* 集合写法

list=["1" "2" "3"]

 

posted @ 2024-03-31 10:20  雪化山河  阅读(12)  评论(0编辑  收藏  举报