我需要寫,如果另一里面如果是的樣子:怎樣寫,如果內部另一如果在bash腳本語言
if(condition)
{
if(condition)
{
//do something
}
//do something
}
如何書寫,但在bash腳本語言?
我需要寫,如果另一里面如果是的樣子:怎樣寫,如果內部另一如果在bash腳本語言
if(condition)
{
if(condition)
{
//do something
}
//do something
}
如何書寫,但在bash腳本語言?
使用if/then構造的條件測試可能是嵌套的。最終結果等效於使用複合比較運算符。
a=3
if [ "$a" -gt 0 ]
then
if [ "$a" -lt 5 ]
then
echo "The value of \"a\" lies somewhere between 0 and 5."
fi
fi
# Same result as:
if [ "$a" -gt 0 ] && [ "$a" -lt 5 ]
then
echo "The value of \"a\" lies somewhere between 0 and 5."
fi
也許你想從一個[Unix Shell Scripting Tutorial]開始(http:// support web.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/unixscripting/unixscripting.html)? – Carpetsmoker
http://www.gnu.org/software/bash/manual/bashref.html#Conditional-Sonstructs – rici
這將幫助你:[Bash入門指南](http://www.tldp.org/LDP/Bash -Beginners-Guide/html/sect_07_01.html) – bprayudha