shell 指令碼寫法:

雪化山河發表於2024-03-31

* 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"]

相關文章