问题
当后台进程结束时,Done
之前的 +
、-
和 符号的含义是什么?
感兴趣的例子
代码 1
(sleep 4s; echo first)&
(sleep 2s; echo second)&
(sleep 1s; echo third)&
[1] Done ( sleep 4s; echo first )
[2]- Done ( sleep 2s; echo second )
[3]+ Done ( sleep 1s; echo third )
代码 2
(echo first)&
(echo second)&
(echo third)&
[1]+ Done ( echo first )
[2]+ Done ( echo second )
[3]+ Done ( echo third )
最佳答案
我的理解是:
1- 已标记或具有 +
的作业是最后发送到后台的作业。
2- 作业被标记或具有 -
被发送到后台倒数第二个。
3- 其他后台作业未标记。
这是我刚刚在我的系统上运行的例子
$bash: /singh/test1 &
[1] 9223
$bash: /singh/test2 &
[2] 9226
$bash: /singh/test3 &
[3] 9234
$bash: /singh/test4 &
[4] 9237
$bash: jobs
[1] Running /singh/test &
[2] Running /singh/test2 &
[3]- Running /singh/test3 &
[4]+ Running /singh/test4 &
我可以从人身上看到 bash
:
There are a number of ways to refer to a job in the shell. The character % introduces a job specification (jobspec). Job number n may be referred to as %n. A job may also be referred to using a prefix of the name used to start it, or using a substring that appears in its command line. For example, %ce refers to a stopped ce job. If a prefix matches more than one job, bash reports an error. Using %?ce, on the other hand, refers to any job containing the string ce in its command line. If the substring matches more than one job, bash reports an error. The symbols %% and %+ refer to the shell’s notion of the current job, which is the last job stopped while it was in the foreground or started in the background. 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 -. A single % (with no accompanying job specification) also refers to the current job.
关于bash - 当后台进程结束时, `+` 之前的 `-` 、 ` ` 和 `Done` 符号是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48837611/