builtin
jobs
List current shell jobs. -p prints process group leader IDs; -r limits to running jobs and -s to stopped jobs. This is not a system-wide process inventory.
Formal Syntax & Structure
bash syntaxbash
jobs [-lnprs] [jobspec]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| jobspec | job identifier | Current shell job to inspect. |
Return Value
exit status
List current shell jobs. -p prints process group leader IDs; -r limits to running jobs and -s to stopped jobs. This is not a system-wide process inventory.
Working Example
Example Snippetbash
sleep 0.3 &pid=$!jobs -p > jobs.txtif grep -Fxq "$pid" jobs.txt; then printf 'job listed\n'else exit 1fiwait "$pid"