我了解到fg %N
的意思是“去任务N
”
我不明白这个命令,也不明白如何使用它。我试图在终端中看到该命令的手动输入,但这没有奏效:
$ man fg
No manual entry for fg.
发布于 2018-01-12 13:28:34
fg
是builtin命令:$ type fg是一个shell内置程序,用于获取关于各个bash命令的信息,使用help
:$ help : fg将作业移到前台。将JOB_SPEC标识的作业放在前台,使其成为当前作业。如果不存在JOB_SPEC,则使用shell对当前作业的概念。退出状态:置于前台的命令状态,或发生错误时失败。1>&2
是重定向的一个例子。要阅读有关重定向的内容,请运行man bash
并转到题为REDIRECTION
的部分。发布于 2018-01-12 13:34:56
第二,首先:fg
是一个bash内置命令,因此您需要引用bash
的手册页。特别是,JOB CONTROL
部分说
Simply naming a job can be used to bring it into the foreground: %1 is
a synonym for ``fg %1'', bringing job 1 from the background into the
foreground. Similarly, ``%1 &'' resumes job 1 in the background,
equivalent to ``bg %1''.
或者,您可以使用shell的交互式help
系统:
$ help fg
fg: fg [job_spec]
Move job to the foreground.
Place the job identified by JOB_SPEC in the foreground, making it the
current job. If JOB_SPEC is not present, the shell's notion of the
current job is used.
Exit Status:
Status of command placed in foreground, or failure if an error occurs.
现在是第一部分。您所述的实际命令实际上是将stdout
重定向到stderr
:它将stdout重定向到名为2的文件,然后将整个命令放入shell的背景中。因此
$ man 1>2&
[1] 4662
在后台运行man
(作为作业[1]
,带有进程ID 4662
) --如果您查看当前目录,很可能会找到一个名为2
的文件及其内容。
What manual page do you want?
您应该使用的命令是1>&2
。
&2
:文件描述符#22&
:名为2
的文件,命令在后台运行有关更多信息,请参见man bash
的D25
部分
https://askubuntu.com/questions/995166
复制相似问题