if then
// goodif [ -d public ]thenecho "public exist"if// goodif [ -d public ]; thenecho "public exist"if// error: if和then写成一行时,条件后必须加上分号if [ -d public ] thenecho "public exist"if// error: shell对空格比较敏感,多个空格和少个空格,执行的含义完全不同// 在[]中,内侧前后都需要加上空格if [-d public] thenecho "public exist"if
if elif then
if [ -d public ]thenecho "public exist"elifthen
循环
switch
常用例子
判断目录是否存在
if [ -d public ]thenecho "public exist"if
