Shell – +/- after a job in the background is done

background-processjob-controlshell

Run a job in the background

$ command &

When it's done, the terminal prints

[n]+    command

or

[n]-    command

So sometimes it's a plus and other times it's a minus following [n].

What does plus/minus mean?

Best Answer

They are to distinguish between current and previous job; the last job and the second last job for more than two jobs, with + for the last and - for the second last one.

From man bash:

The previous job may be referenced using %-. If there is only a single job, %+ and %- can both be used to refer to that job. In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a +, and the previous job with a -.

Example:

$ sleep 5 &
[1] 21795

$ sleep 5 &
[2] 21796

$ sleep 5 &
[3] 21797

$ sleep 5 &
[4] 21798

$ jobs
[1]   Running                 sleep 5 &
[2]   Running                 sleep 5 &
[3]-  Running                 sleep 5 &
[4]+  Running                 sleep 5 &

$ 
[1]   Done                    sleep 5
[2]   Done                    sleep 5
[3]-  Done                    sleep 5
[4]+  Done                    sleep 5
Related Question