Skip to content

Instantly share code, notes, and snippets.

@thejhh
Last active June 17, 2020 11:44
Show Gist options
  • Select an option

  • Save thejhh/bf4abc27e915dc294712df3127594a5e to your computer and use it in GitHub Desktop.

Select an option

Save thejhh/bf4abc27e915dc294712df3127594a5e to your computer and use it in GitHub Desktop.
bash test vs [ ]
$ test "$memmb" -gt 4000
-bash: test: : integer expression expected
$ test $memmb -gt 4000
-bash: test: -gt: unary operator expected
$ [ $memmb -gt 4000 ]
-bash: [: -gt: unary operator expected
$ [ "$memmb" -gt 4000 ]
-bash: [: : integer expression expected
$ [ "$memmb" -gt 4000
-bash: [: missing `]'
$ [ "$memmb" -gt 4000 ]
-bash: [: ! 123: integer expression expected
$ [ $memmb -gt 4000 ]
$ echo $?
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment