Bash: '$(( ))' means 'expr' and '[ ]' means 'test'?

bash, linux

Solution

the `((...))` construct is equivalent to the bash builtin `let`. `let` does mostly the same stuff which `expr` does.

the `$((...))` construct, note the `$` at the beginning, will substitute the output of the expression inside just like `$(...)` does.

the `[...]` construct is in fact just another name for `test`.

see the bash help pages for more information.

- `help "("`

- `help let`

- `help [`

- `help test`

see also:

- http://mywiki.wooledge.org/BashFAQ/031

- http://mywiki.wooledge.org/ArithmeticExpression

Problem

I have been working with some bash scripting lately and been looking through the man pages. From what I have gathered, does `$(( ))` mean `expr` and `[ ]` mean `test`? For `$(( ))`: ``` echo $(( 5 + 3 )) ``` has the same output as: ``` echo $(expr 5 + 3) ``` For `[ ]`: ``` test 'str' = 'str' ``` has the same success value as: ``` [ 'str' = 'str' ] ``` Did I get my understanding right?

Original source