1

In bash when I try to check for null or empty i get syntax error message

DEFAULT_VALUE="0"
CRAM_QUERY=$(mycommand) 

if [[ "$CRAM_QUERY" == "NULL" ] || ["$CRAM_QUERY" == ""]] ; then 
   CRAM_QUERY="$DEFAULT_VALUE"
fi
kumar
  • 8,207
  • 20
  • 85
  • 176
  • 5
    Add a shebang and then paste your script there: http://www.shellcheck.net/ – Cyrus Jul 24 '20 at 01:09
  • Does this answer your question? [How to represent multiple conditions in a shell if statement?](https://stackoverflow.com/questions/3826425/how-to-represent-multiple-conditions-in-a-shell-if-statement) – Digvijay S Jul 24 '20 at 10:47

1 Answers1

0

This should work:

DEFAULT_VALUE="0"
CRAM_QUERY=$(mycommand) 

if [[ "$CRAM_QUERY" == "NULL" || "$CRAM_QUERY" == "" ]] ; then 
   CRAM_QUERY="$DEFAULT_VALUE"
fi
Dominik
  • 6,078
  • 8
  • 37
  • 61