percent
% in shell context refers to job control, bringing background jobs to the foreground
TLDR
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))
SYNOPSIS
% [jobspec_]
DESCRIPTION
% 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.
JOB SPECIFICATIONS
% or %+ or %%
Current (most recent) job%-
Previous job%n
Job number n%string
Job whose command starts with string%?string
Job whose command contains string
CAVEATS
Job control requires an interactive shell. Not available in scripts by default.The % interpretation is context-dependent: job control at command position, modulo in arithmetic, format specifier in strings.Job numbers reset when the shell restarts.
