LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

percent

% in shell context refers to job control, bringing background jobs to the foreground

TLDR

Bring most recent background job to foreground
$ %
copy
Bring job number N to foreground
$ %[N]
copy
Bring job starting with string to foreground
$ %[string]
copy
Bring job containing string to foreground
$ %?[string]
copy
Use modulo operator in arithmetic
$ echo $((10 % 3))
copy

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.

SEE ALSO

fg(1), bg(1), jobs(1), kill(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid