2022年11月1日星期二

shell if and or

 

  • && (AND) : if [ condition1 ] && [ condition2 ]; then 
       if [ -f $src/* ] && [ -d $dest ]; then 

          echo "there are files under $src"
          cp -rf $src/* $dest/
       else
          echo " directory $
dest is not found, or no files under $src" 
       fi


  • || (OR) : if [ condition1 ] || [ condition2 ]; then 
       

没有评论: