brackets vs parentheses - single and double

hi, unix gurus.

i am wondering if someone can give me a clear explanation of the differneces between parentheses and brackets, both single and double.

i have heard that double parentheses (( are used for numerical expressions and that single brackets [ are used for strings. but i see very different behavior on this forum and elsewhere. i would love some clarity!

thanks for your help as usual.

First read the man page for test.

[[ and [ are shell builtins (in modern shells)
for test. test or [[ - you have to complete them with ]] - are use either in if statments or in combined statements

if [[ 1 -eq $var ]] ; then
   echo "hi there"
fi
# same thing written another way as a one-liner
[[ 1 -eq $var ]] &&  echo "hi there"

# test if a file exists
[[ -f somefile ]] && echo "found somefile "

the -eq -gt -lt -ge -le comparisons are for comaring integer numbers in [[ ]]
comparing strings- [[ "$string1" = "$string2" ]]

There are other modern operators for testing file times: for example -ot -nt
See the ksh man page

$(( )) does arithmetic operations - whole numbers (long integers).
allowed operators are + - * / and some others like %.
$(( 3 + 1 )) evaluates a 4

$( some command [s]) runs one or more commands in background
it works just like the backticks: `command`
read all of a file into an envrionment variable
myvar=$(< somefile)
put the date in a variable
myvar=$( date )