$ operator的三種擴展模式
${variable_name}
$(command)
$((expression))
字串操作
${variable:start_position}
${variable:start:length}
${#variable}字串長度
算術運算
$((expression))
expr expression
$[expression]
declear -i var=expression
let expression
r=$((2+3))
r=`expr 3+2`
r=$[4+5]
declare -i r=5*5
let i=5+5
條件判斷
if test1; then
statements
elif test2; then
statements
...
else
statements
fi
測試條件仿照c的邏輯,非null/0為真
if [-d /root/tmp]; then
echo '/root/temp directory exists!'
else
echo "/root/temp directory doesn't exist!"
沒有留言:
張貼留言