写在前面:案例.常用.归类.解释说明.(By Jim)使用if-then语句如果命令的退出状态是0(成功执行命令),将执行then后面的所有命令.如果命令的退出状态是0以外的其他值,那么then后面的命令将不会执行,bash shell会移动到脚本的下一条命令. #!/bin/bash # testing the if statement if date then echo "it worked" fi (date返回0,执行then语句it worked) #!/bin/bash #…
写在前面:案例.常用.归类.解释说明.(By Jim) for命令重复一系列的命令是一种常见的编程实践. #!/bin/bash # basic for command for test in A B C D E F G H I J K L M N O P Q do echo The next letter is $test done 结果:The next letter is AThe next letter is BThe next letter is CThe next letter is…