一、if-then句型
1.if-then句型结构如下:
 

if command
  then
     command
  fi
2.eg:
  $cat test1.sh
  #!/bin/bash
  #zhis is test
  if date
  then
     echo "it worked"
  fi
  eg:
   cat test.sh
  #!/bin/bash
  if
  data
  then
  echo  "it's not work"
  fi
  echo "we're outside of zhe statement"

  # sh test.sh
  test.sh: line 3: data: command not found
  we're outside of zhe statement
3.if-then语句的另一种形式:
  if command; then
     commands
  fi
4.if-then-else语句
  if command
  then
     command
  else
     command
  fi
  eg:
  #!/bin/bash
  #test
  testuser=baduser
  if grep $testuser /etc/passwd
  then
    echo the files for user $testuser are:
    ls -a /home/$testuser/.b*
  else
    echo "the user name $testuser doesn't exist on this system"
  fi