← 返回命令列表

Linux command

parenthesis 命令

文本

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Run commands in a subshell

(cd [/tmp] && [command])

Create an array

array=([one] [two] [three])

Command grouping without subshell

{ [command1]; [command2]; }

Function definition

function_name() { [commands]; }

Arithmetic evaluation

(( count++ ))

说明

Parentheses ( ) in shell have several distinct uses depending on context: Subshell execution: Commands in (...) run in a child shell. Environment changes (cd, variable assignments) don't affect the parent shell. Array literals: In bash/zsh, array=(a b c) creates an array. Function definition: name() { ... } defines a function (parentheses are part of syntax, not grouping). Command substitution: $(...) captures command output. Arithmetic: ((...)) performs arithmetic evaluation, $((...)) expands to the result.

FAQ

What is the parenthesis command used for?

Parentheses ( ) in shell have several distinct uses depending on context: Subshell execution: Commands in (...) run in a child shell. Environment changes (cd, variable assignments) don't affect the parent shell. Array literals: In bash/zsh, array=(a b c) creates an array. Function definition: name() { ... } defines a function (parentheses are part of syntax, not grouping). Command substitution: $(...) captures command output. Arithmetic: ((...)) performs arithmetic evaluation, $((...)) expands to the result.

How do I run a basic parenthesis example?

Run `(cd [/tmp] && [command])` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more parenthesis examples?

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