Guest User

Untitled

a guest
Mar 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. value=""
  4. if [ -n $value ]
  5. then
  6. echo "value is non-zero"
  7. fi
  8.  
  9. #!/usr/bin/env bash
  10.  
  11. value=""
  12. if [[ -n $value ]]
  13. then
  14. echo "value is non-zero"
  15. fi
  16.  
  17. [[ expression ]]
  18. Return a status of 0 or 1 depending on the evaluation of the conditional expression expression. Expressions are composed of the pri‐
  19. maries described below under CONDITIONAL EXPRESSIONS. Word splitting and pathname expansion are not performed on the words between
  20. the [[ and ]]; tilde expansion, parameter and variable expansion, arithmetic expansion, command substitution, process substitution,
  21. and quote removal are performed. Conditional operators such as -f must be unquoted to be recognized as primaries.
  22.  
  23. test "$1"
  24. test ! "$1"
  25.  
  26. test -n "$1"
  27. test -z "$1"
  28.  
  29. [ "-${z:-n}" "$var" ]
  30.  
  31. [[ "-${z:-n}" "$var" ]]
Add Comment
Please, Sign In to add comment