1:保存命令的结果
$(ls -l /) 或者 `ls -l /`
2:判断 [[]] 与 []
[ -z $(ls -l /)] 或者 test
一个目录是否为空: [[ -z $(ls /a)]]||&&echo empty|| echo “not empty”
3:$(()) 算数运算
VAR=1
VAR=$(($VAR+1))
echo $VAR
4:while 循环
The general syntax as follows for bash while loop:
while [ condition ]
do
command1
command2
commandN
done
The condition is evaluated, and if the condition is true, the command1,2…N is executed.
This repeats until the condition becomes false.
The condition can be integer ($i < 5), file test ( -e /tmp/lock ) or string ( $ans != "" )
5: $<
#!/bin/csh
echo -n “Enter your name : ”
set yname = $<