Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 0.49 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Checking a variable is set and value in ksh
  2. ./export_data.sh <user> <type> [REFRESH]
  3.        
  4. if [ -n $REFRESH ] && [ $REFRESH == "REFRESH" ]
  5. then
  6.     echo "variable is set and the expected value";
  7.     # do stuff
  8. fi
  9.        
  10. if [ -n $REFRESH ]
  11. then
  12.     if [ $REFRESH == "REFRESH" ]
  13.     then
  14.         echo "variable is set and the expected value";
  15.         # do stuff
  16. fi
  17.        
  18. if [ "${REFRESH:-unset}" = "REFRESH" ]
  19. then ...
  20.        
  21. if [ "$REFRESH" = "REFRESH" ]
  22. then ...
  23.        
  24. if [ "${REFRESH:-unset}" != unset ]