Link to home
Start Free TrialLog in
Avatar of beer9
beer9Flag for India

asked on

Difference of (( )) and $(( )) in bash script

Hello, While going through reading some bash tutorial I am stuck here..

(( )) Evaluates and assigns value to a variable and does math in a shell
$(( )) Evaluates the enclosed expression

Open in new window


I am not able to get where should I use (( )) and $(( )). Could someone please provide me an example to understand it better. Thanks!
ASKER CERTIFIED SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
$(( )) is for mathematical evaluation (finding a value)
(( )) is for logical expression (true or false conditions)
(( )) is for mathematical logical conditions
(( 7+8 == 15 )) && echo true

[[ ]] is for non mathematical logic
name=beer9
[[ $name == "beer9" ]] && echo equal
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial