%).
Syntax Variations
The Bash shell supports several jobspec formats for pattern matching and state-based referencing:State Resolution
The shell maintains internal pointers to track job states, specifically defining the “current” and “previous” jobs:- Current Job (
%+,%%, or%): The most recently suspended job. If no jobs are currently suspended, it resolves to the most recently backgrounded job. - Previous Job (
%-): The job that held the “current” status immediately prior to the active current job.
Resolution Rules and Ambiguity
When utilizing string-based jobspecs (%str or %?str), the shell evaluates the provided string against the command lines stored in the job table.
- Prefix Matching:
%strrequires the command line to start exactly withstr. - Substring Matching:
%?strrequiresstrto exist anywhere within the command line. - Ambiguity Exception: If a string-based jobspec matches multiple active jobs in the job table, the shell cannot safely resolve the target. It will abort the operation and raise an
ambiguous job specerror. - Missing Job Exception: If no jobs match the integer or string provided, the shell raises a
no such joberror.
Tired of Poor Bash Skills? Fix That With Deep Grasping!Learn More





