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

Recently, I have been working with some bash scripts and browsing the manual pages. From what I have gathered, $(( ))mean exprand [ ]mean test?

For $(( )):

echo $(( 5 + 3 ))

has the same result as:

echo $(expr 5 + 3)

For [ ]:

test 'str' = 'str'

has the same meaning of success as:

[ 'str' = 'str' ]

Did I understand my opinion correctly?

+5
source share
2 answers

The design is ((...))equivalent to bash builtin let. letdoes basically the same stuff as expr.

The design $((...)), pay attention to $at the beginning, will replace the output of the expression inside the same way $(...).

[...] test.

bash .

  • help "("
  • help let
  • help [
  • help test

. :

+9

[ ] test

$(( )), expr. , expr.

+6

All Articles