Intermediate Linux & Shell Scripting
Q68 / 100

What is the difference between "$(( ))" (arithmetic expansion) and a regular variable expansion "$VAR" in bash?

Correct! Well done.

Incorrect.

The correct answer is A) "$(( expression ))" evaluates the enclosed expression as arithmetic, returning a numeric result for operations like addition, while "$VAR" simply substitutes the literal string value of a variable with no arithmetic

A

Correct Answer

"$(( expression ))" evaluates the enclosed expression as arithmetic, returning a numeric result for operations like addition, while "$VAR" simply substitutes the literal string value of a variable with no arithmetic

Explanation

Without arithmetic expansion, "$VAR + 1" would be treated as a literal string concatenation in many contexts; "$(( VAR + 1 ))" performs actual integer arithmetic and returns the computed result.

Progress
68/100