·常用的shell
/bin/sh /bin/bash /bin/ksh /usr/bin/ksh /bin/tcsh
函数与过程
·函数
function function_name(){
}
或
function_name(){
}
===========================
·示例
function showdot() {
#show dot per x seconds
while [ true ] ; do
sleep 3;
echo -n ".";
done;
}
============================
·调用函数
showdot
控制结构
·if控制结构
if [ test_command ]
then
cmd
fi
=====================================
if [ test_command ]
then
cmd
else
cmd
fi
=====================================
if [test_command ]
then
cmd
elif [ test_command ]
then
cmd
elif [ test_command ]
then
cmd
else
cmd
fi
======================================
·for循环
for loop_variable in argument_list
do
cmd
done
======================================
·while语句
while [ test_command ]
do
cmd
done
======================================
·until语句
until [ test_command ]
do
cmd
done
======================================
·case语句
case $variable in
match_1)
cmd
;;
match_2)
cmd
;;
.
.
.
*)
cmd
;;
esac
========================================
break、continue从for或while循环中断与继续执行
if [ test_command ]
then
cmd
fi
=====================================
if [ test_command ]
then
cmd
else
cmd
fi
=====================================
if [test_command ]
then
cmd
elif [ test_command ]
then
cmd
elif [ test_command ]
then
cmd
else
cmd
fi
======================================
·for循环
for loop_variable in argument_list
do
cmd
done
======================================
·while语句
while [ test_command ]
do
cmd
done
======================================
·until语句
until [ test_command ]
do
cmd
done
======================================
·case语句
case $variable in
match_1)
cmd
;;
match_2)
cmd
;;
.
.
.
*)
cmd
;;
esac
========================================
break、continue从for或while循环中断与继续执行