bash: What is a jobspec

american-ninja-warrior picture american-ninja-warrior · Jan 27, 2016 · Viewed 7.9k times · Source

While reading documentation [1], the term "jobspec" appears a few times.

What is a jobspec?

[1] https://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html

Answer

Rany Albeg Wein picture Rany Albeg Wein · Jan 27, 2016

The job control section of Greg's Bash Guide describes this as follows:

A job specification or "jobspec" is a way of referring to the processes that make up a job. A jobspec may be:

  • %n to refer to job number n.
  • %str to refer to a job which was started by a command beginning with str. It is an error if there is more than one such job.
  • %?str to refer to a job which was started by a command containing str. It is an error if there is more than one such job.
  • %% or %+ to refer to the current job: the one most recently started in the background, or suspended from the foreground. fg and bg will operate on this job if no jobspec is given.
  • %- for the previous job (the job that was %% before the current one).