← 返回命令列表

Linux command

percent 命令

文本

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

常用示例

Bring most recent background job to foreground

%

Bring job number N to foreground

%[N]

Bring job starting with string to foreground

%[string]

Bring job containing string to foreground

%?[string]

Use modulo operator in arithmetic

echo $((10 % 3))

说明

% in shell context refers to job control, bringing background jobs to the foreground. It's shorthand for the fg command. When a command is suspended (Ctrl+Z) or run in background (&), it gets a job number. The % notation provides quick access to these jobs. In arithmetic contexts $(( )), % is the modulo operator, returning the remainder of integer division. In prompt strings (PS1), % introduces escape sequences in zsh for dynamic prompt elements.

FAQ

What is the percent command used for?

% in shell context refers to job control, bringing background jobs to the foreground. It's shorthand for the fg command. When a command is suspended (Ctrl+Z) or run in background (&), it gets a job number. The % notation provides quick access to these jobs. In arithmetic contexts $(( )), % is the modulo operator, returning the remainder of integer division. In prompt strings (PS1), % introduces escape sequences in zsh for dynamic prompt elements.

How do I run a basic percent example?

Run `%` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more percent examples?

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