Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash: What is a jobspec

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

like image 336
american-ninja-warrior Avatar asked Jan 27 '16 00:01

american-ninja-warrior


People also ask

What does [- Z $1 mean in Bash?

$1 means an input argument and -z means non-defined or empty. You're testing whether an input argument to the script was defined when running the script. Follow this answer to receive notifications.

What are $( and $(( )) in Bash?

$(...) is an expression that starts a new subshell, whose expansion is the standard output produced by the commands it runs. This is similar to another command/expression pair in bash : ((...)) is an arithmetic statement, while $((...)) is an arithmetic expression. Follow this answer to receive notifications.

What does & disown after a command do?

The disown command in Linux is used to remove jobs from the job table. You can also use it to keep a longer and more complex job running in the background even after you log out of the server.

What is a job in shell?

Jobs are managed by the operating system as a single process group, and the job is the shell's internal representation of such a group. This is defined in POSIX as: A set of processes, comprising a shell pipeline, and any processes descended from it, that are all in the same process group.


1 Answers

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).
like image 68
Rany Albeg Wein Avatar answered Oct 11 '22 10:10

Rany Albeg Wein