Why Are There Single "[]" and Double "[[]]" Brackets In Bash? What's the Difference?

Well, since you asked, let's go over some of the differences. Here are the most important ones:

  2. [[ is not as compatible, it won't necessarily work with whatever /bin/sh points to. So [[ is the more modern Bash / Zsh / Ksh option.

For the most part, the rest is just some nicer syntax. Generally double brackets "[[]]" are better to use if you're you don't need it to be portable. The main reasons are:

  1. You don't have to worry about quoting the left-hand side of the test so that it actually gets read as a variable.


-Until next time!

January 20 2020

Add or review comments

Please leave your comment

Existing comments

Comments 1

Barry allen
thanks for information ! https://get-shareit.com https://get-vidmateapk.com

Get notified about new publications and product updates.
Please note we do not share information to anyone.