输入--0
标准输出--1
错误输出--2
输出的标志 > ,>是覆盖,>>是在原内容上追加
输入的标志<,<<<是单行输入,<<是多行输入 通过同样的名字结束,但由于read的特性,所以只能读取一行。
shell变量有五种
本地 name=5
局部 local--只能用于函数
环境 export
特殊
$$
$#--获取参数的个数
$*---获取某一位置的参数($1,$2..)
$@---等同于$*
$?----输出上一条指令的执行状态,0为正确 其余全为错
$BASHPID--打印当前进程的实际ID
本地 使用{}
运算符
1.算术运算符 let
C=$(($A+$B))
C=`expr $A + $B`
C=$[$A+$B]
2.逻辑运算符 test
[ expression ]
[[ expression ]]
控制循环
1.for
for name in 1 2 3
do
commands
done
for((i=1;i<=5;i++)) 死循环 for((;;))
do do
commands commands
done done
2.while
while commands 死循环 while ((1))
do do
commands commands
done done
3.dowhile
4. switch...case
case name in
1)
commands
;;
2)
commands
;;
....
esac
5.if
if commands
then
commands
elif commands
then
commands
else
commands
fi