Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. string1 has not been initialized, it has no defined value
  2.  
  3. 1. Non-quote string in test brackets. Wrong results !
  4. > [ -n $string1 ] && echo "String1 is not null"
  5. -> Show "String1 is not null" --> Wrong results.
  6. 2. Quote string within test brackets.
  7. > [ -n "$string1"] && echo "String1 is not null"
  8. -> --> This works fines
  9. 3. string1 stands naked. Must quoting. See the following examples
  10. 3.1 Unquoted
  11. > [ $string1 ] && echo "String1 is not null"
  12. -> --> This works fine.
  13. > string1="a = b"
  14. > [ $string1 ] && echo "String1 is not null"
  15. -> --> Wrong result !
  16. 3.2 Quoted
  17. > string1="a = b"
  18. > [ "$string1" ] && echo "String1 is not null"
  19. -> Show "String1 is not null" --> This works fine
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement