1. 显示字符串
Echo “String”
2. for 循环
for((i = 1; i < 100; i += 2))
do
echo $i
done
参考 https://www.garron.me/en/articles/bash-for-loop-examples.html
3. 接受输入 read
read name
echo "Welcome $name"
4. if-elif-else
if [[ var1 -lt var2 ]]; then
echo "X is less than Y"
elif [[ var1 -eq var2 ]]; then
echo "X is equal to Y"
else
echo "X is greater than Y"
fi
5. 逻辑运算符
if [ $var1 == "y" ] || [ $var1 == "Y" ]; then
echo "YES"
else
echo "NO"
fi