if
if始终只是判断程序执行结果的exit status,即$?,0表示true,非0表示false。
1 | [ -d /root/test ]等同于test -d /root/test |
shell 中的条件判断 “并且” “或者”
并且,and
1 | if [ c1 -a c2 ]; then |
或者,or
1 | if [ c1 -o c2 ]; then |
加减
1 | let a=$s+1 |
定时任务中脚本不能执行
1 | 手动执行脚本可以运行,但在crontab里面不行的解决方法 |
if始终只是判断程序执行结果的exit status,即$?,0表示true,非0表示false。
1 | [ -d /root/test ]等同于test -d /root/test |
并且,and
1 | if [ c1 -a c2 ]; then |
或者,or
1 | if [ c1 -o c2 ]; then |
1 | let a=$s+1 |
1 | 手动执行脚本可以运行,但在crontab里面不行的解决方法 |