if condition1
then
command1
elif condition2
then
command2
else
commandn
fi
方式一
for n in12
3doecho
$ndone
或for n in12
3; do
echo
$n; done
或for n in ; do
echo
$n; done
方式二for ((i = 0; i <= 5; i++))
doecho
"welcome $i times"
done
或for ((i = 0; i <= 5; i++)); do
echo
"welcome $i times"; done
方式一
while expression
docommand
…done
方式二i=1
while ((i<=3))
doecho
$ilet i++
done
let 命令是 bash 中用於計算的工具,用於執行乙個或多個表示式,變數
計算中不需要加上 $ 來表示變數。自加操作: let no++ 自減操作: let no —
方式三:無限迴圈
while
true
docommand
done
case 值 in
模式 1)
command1
command2
...commandn
;;模式 2)
shell程式設計筆記(五)
我們再來重新說一下exec命令 這個命令很有用,我們可以把乙個已經開啟的檔案的檔案描述符複製到另乙個檔案描述符中,示例如下 touch test echo this is a test test exec 6 test exec 7 6 date 7 cat test 關閉檔案描述符 exec 檔案...
實驗五 shell指令碼程式設計
專案詳情 這個作業屬於哪個課程 這個作業的要求在 學號 姓名 15041408 袁昊 作業學習目標 建立目錄並在目錄下編寫shell指令碼並執行 建立乙個新的資料夾 1.讓使用者輸入乙個字串,如果使用者輸入的是hello,請輸入hello 使用者姓名首字母縮寫,否則輸出請輸入hello。2.編寫一指...
驗五 shell指令碼程式設計
專案 這個作業屬於哪個課程 這個作業的要求在 學號 姓名 17041430 楊太勝 作業學習目標 1 了解shell指令碼的概念及使用 2 掌握shell指令碼語言的基本語法 3 學習簡單的shell指令碼程式設計 1.讓使用者輸入乙個字串,如果使用者輸入的是 hello 請輸入 hello 使用者...