Even since I started writing Bash script, I always use [[, the double square brackets, never the single one version unless compatibility has to be taken into account. Why did I choose it? It’s because I read [[ is faster. I’ve never tried to confirm it by myself, although I do know that [ is a type of shell builtin command and [[ is type of shell keyword, and [ is equivalent to test, which is also a builtin command in Bash for very long time.1

From time to time, I often see people still using [ even in the script with a few Bash-only syntaxes or features. They are clearly not writing with compatibility as a requirement. If I have a chance, then I would probably advise the coder to change to [[. I had done so a few times in the past.

However, I never see the numbers, so here they are:

i=0; COUNT=100000;
time while [ -z '' ]; ((++i < COUNT)); do :; done
1.668s

i=0; COUNT=100000;
time while [[ -z '' ]]; ((++i < COUNT)); do :; done
1.108s

i=0; COUNT=100000;
time while [ a = a ]; ((++i < COUNT)); do :; done
1.673s

i=0; COUNT=100000;
time while [[ a = a ]]; ((++i < COUNT)); do :; done
1.244s

The numbers really speak for themselves and why you should use [[ very well, 50.5% and 34.5% slower in two test cases. Imagine that you are using /usr/bin/test and note that COUNT is only 100,000 / 100 = 1,000:

i=0; COUNT=1000;
time while /usr/bin/test -z ''; ((++i < COUNT)); do :; done
1.881s

Roughly, 1.881 * 100 = 188.1s, that’s 16,877% slower. Holy snaily!

If you are new to Bash, just use [[.