Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 19
    @TheVillageIdiot and @Hedgehog, are you using bash shell? The double bracket isn't universally supported. Here's a SO answer on that point: stackoverflow.com/questions/669452/… Commented Jul 2, 2011 at 14:54
  • 9
    And in Busybox ash with default compilation options [[ ]] is supported, but doesn't in fact provide any different functionality to [ ]. If portability is a concern, stick with [ ] and use the necessary workarounds. Commented May 31, 2012 at 15:34
  • 9
    ...if using bash constructs in a shell script, the first line of the script should be: #!/bin/bash (and not #!/bin/sh, ksh, etc) Commented Sep 12, 2014 at 1:23
  • 5
    When using double square brackets in bash, you do not need to quote the variables. Commented Aug 11, 2017 at 5:58
  • 2
    @AdamKatz Portability and deprecation of features in dash don't matter since this is about bash. Commented May 22, 2021 at 20:09