special-parameter

Bash $! — most recent background job PID

Expands to the process ID of the most recent job put into the background. Save promptly when coordinating jobs.

Formal Syntax & Structure

bash syntaxbash
$!

Return Value

integer text

Background job PID when available.

Working Example

Example Snippetbash
true &job=$!wait "$job"printf 'job status=%s\n' "$?"printf 'flags=%s\n' "$-"
Bash Reference