函數腳本shell
function func()函數
{spa
程序段ip
}it
調用函數直接func就能夠了io
=============================================================================================================function
利用判斷符號[]變量
=============================================================================================================循環
shell script的默認變量程序
scriptname opt1 opt2 opt3 opt4
$0 $1 $2 $3 $4
shift的功能至關於把默認變量循環右移一次
=============================================================================================================
if [ 條件判斷式 一 ]; then
文本
elif [ 條件表達式二 ]; then
文本
else
文本
fi
=============================================================================================================
case $1 in
選項1)
程序段
;;
選項2)
程序段
;;
*) #最後一個變量內容都會用*來表明全部其餘值
exit1
;;
esac
=============================================================================================================
for $var in $tmp
do
文本段
done
其中$tmp能夠是$(seq 1 10)表示1到10連續的取值。