← 返回命令列表

Linux command

double-parenthesis 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Arithmetic evaluation

(( x = 5 + 3 ))

Increment variable

(( count++ ))

Conditional test

(( x > 10 )) && echo "big"

Capture arithmetic result

result=$(( a * b ))

Complex expression

(( result = (a + b) * c / d ))

说明

(( )) is the shell's arithmetic evaluation construct. It evaluates mathematical expressions and returns success (0) if the result is non-zero, failure (1) if zero. Inside ((...)), variables don't need the $ prefix and whitespace is ignored. Standard C-style operators work as expected. $((...)) performs arithmetic expansion, substituting the result. ((...)) evaluates without substitution (for side effects like assignment). ```bash

FAQ

What is the double-parenthesis command used for?

(( )) is the shell's arithmetic evaluation construct. It evaluates mathematical expressions and returns success (0) if the result is non-zero, failure (1) if zero. Inside ((...)), variables don't need the $ prefix and whitespace is ignored. Standard C-style operators work as expected. $((...)) performs arithmetic expansion, substituting the result. ((...)) evaluates without substitution (for side effects like assignment). ```bash

How do I run a basic double-parenthesis example?

Run `(( x = 5 + 3 ))` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more double-parenthesis examples?

This page includes 5 examples for double-parenthesis, plus related commands for nearby Linux tasks.