hellopasswdshell
[root@localhost ~]# for i in `seq 1 5` > do > echo $i > done 1 2 3 4 5 [root@localhost ~]# for i in `seq 1 5`; do echo $i; done 1 2 3 4 5
[root@localhost ~]# a=5 [root@localhost ~]# if [ $a -gt 3 ] > then > echo ok > fi ok [root@localhost ~]# if [ $a -gt 3 ]; then echo ok; fi ok [root@localhost ~]# cd shell [root@localhost shell]# vi 1.sh 添加 1 #!/bin/bash 2 a=5 3 if [ $a -gt 3 ] 4 then 5 echo ok 6 fi [root@localhost shell]# sh 1.sh ok [root@localhost shell]# ./1.sh ok
[root@localhost shell]# vi 1.sh 添加 1 #!/bin/bash 2 a=1 3 if [ $a -gt 3 ] 4 then 5 echo ok 6 else 7 echo error 8 fi [root@localhost shell]# sh -x 1.sh + a=1 + '[' 1 -gt 3 ']' + echo error error
[root@localhost shell]# vi 1.sh 添加 1 #!/bin/bash 2 a=5 3 if [ $a -gt 1 ] 4 then 5 echo ">1" 6 elif [ $a -lt 6 ] 7 then 8 echo "<6 && >1" 9 else 10 echo error 11 fi [root@localhost shell]# sh -x 1.sh + a=5 + '[' 5 -gt 1 ']' + echo '>1' >1
[root@localhost shell]# if (($a>1)); then echo ok; fi ok
修改於 180206bash