The fg built-in resumes a job in the foreground.

Syntax

  • fg [job…]

Description

The fg built-in brings the specified job to the foreground and sends the SIGCONT signal to the job. As a result, the job is resumed in the foreground (if it has been suspended). The built-in then waits for the job to finish and returns the exit status of it.

The name of the job is printed when the job is resumed. When not in the POSIXly-correct mode, the job number is also printed.

The built-in can be used only when job control is enabled.

Operands

job

The job ID of the job to be resumed.

If more than one job is specified, they are resumed in order, one at a time. The current job is resumed if none is specified.

The percent sign (%) at the beginning of a job ID can be omitted if the shell is not in the POSIXly-correct mode.

Exit status

The exit status of the fg built-in is that of the (last) job resumed. The exit status is non-zero when there was some error.

Notes

The fg built-in is a mandatory built-in.

You cannot specify more than one job in the POSIXly-correct mode.