Q:

When dealing with numbers in bash when is [[ ]] preferred over (( ))

Just out of curiosity is there ever a reason to prefer something like:
while [[ $number -lt 10 ]]

over
while (( $number < 10 )) 

They seem to do the same thing. I'm wondering if maybe there is a performance benefit with one of them or maybe some portability concerns with [[ ]]? 

A:

Neither is standard, so portability is not an issue. If you are only performing simple comparisons, there is little difference betwee
if [[ $number -lt 10 ]]

and
if (( number < 10 ))

aside from the ability to drop the $ from the second (since all strings are assumed to be variables and dereferenced) and readability.
You might prefer [[...]] when your conditional combines arithmetic and non-arithmetic tests:
if [[ $number -lt 10 && $file = *.txt ]]

vs
if (( number < 10 )) && [[ $file = *.txt ]]

You would probably prefer (( ... )) if your comparison involved some computations:
if (( number*2 < 10-delta ))

vs the needlessly complex
if [[ $(( number*2 )) -lt $(( 10-delta )) ]]

A:

Some time ago when you wanted to have any kind of comparisons you was using program "test", which was usually symlinked to name "[".
So you had expressions like:
if [ ..... ]; then

test by default compared asciibetically, and if you wanted numerical comparison, you had to use -lt/-gt and similar.
Then, bash got it's own internal test engine. To use it you use [[.
So the same syntax you had earlier:
if [ ... ]; then

could be rewritten as:
if [[ ... ]]; then

and do the same, with the exception that comparison was done in bash itself, and didn't require fork/exec of test program.
Since now it's not call to external program, it's simpler to add another way to compare numerically. Hence (( )) appeared.
It has certain benefits, but one that is commonly overlooked is that it imposes numerical context.
Which means that you can have something like:
i=1
(( i++ ))
echo $i # will return 2

Long story short - for comparisons, it doesn't matter much. but it pays to learn more about (( )) and [[ ]] in man bash.

