Deepak
Deepak

Reputation: 29

what does the + and the - symbols indicate when a "jobs" command is executed in unix?

When I run the jobs command in CUI to check the jobs. I will get the result like below.

[4]-   Stopped  Passwd.
[5]+   Stopped  Cat > d1.

I didn't get, why + and - is used?

Can anyone explain me the same?

Upvotes: 3

Views: 1577

Answers (1)

torek
torek

Reputation: 489093

Technically this is specific to the shell you're using (which I suspect is bash), but as far as I know all shells assign the same meaning here, taken from venerable1 csh: + is the "most current" job, the one that fg with no argument will resume, and - is the "previous" job. When the "current" job finishes, the previous becomes the current.

You can also refer to these as %+ and %-, in fg and bg commands, and use %- and %+ as commands (and % with no argument, or %%, means the same as %+).


1Or some other less flattering adjective. :-)

Upvotes: 4

Related Questions