條件測試
1.test命令:
文件屬性測試
字符串測試
算術測試
語法: test EXPRESSION
或
[ EXPRESSION ]
在bash中還有一個` `,它是[]的提高版本。
` EXPRESSION `
[ 10 \> 9] [[ 10 > 9]]
2. if 的語法結構
if test-commands; then consequent-commands; fi
或
if test-commands; then
consequent-commands
fi
或
if test-commands
then
consequent-commands
fi
3.if...else...fi
if []
then
else
fi
4.if...elif...else...fi
if [];then
commands
elif [];then
commands
else
commands
fi
5.case 語句
case EXPRESSION in
PATTERN1)
commands;;
PATTERN2)
commands;;
esac