Ctrl-z 后重新进入交互模式

Tom*_*Tom 78 linux terminal shell

在交互模式下(在OctavegnuplotR等中)我偶尔会错误地按Control+ z。这会暂停程序并将我踢回终端。

是否可以重新进入原始交互模式(所有存储的变量)?

重现:

~> octave
octave:1> a = [1:10];
octave:2> ^Z
[1]+  Stopped                 octave
~> 
Run Code Online (Sandbox Code Playgroud)

如何使用a定义的变量恢复会话?

小智 103

在终端中输入fg并点击enter

   fg [jobspec]
          Resume jobspec in the foreground, and make
          it  the  current  job.   If jobspec is not
          present, the shell’s notion of the current
          job  is used.  The return value is that of
          the command placed into the foreground, or
          failure  if  run  when job control is dis-
          abled  or,  when  run  with  job   control
          enabled,  if  jobspec  does  not specify a
          valid job or jobspec specifies a job  that
          was started without job control.
Run Code Online (Sandbox Code Playgroud)


slh*_*hck 16

键入以下命令再次将作业拉到前台:

fg
Run Code Online (Sandbox Code Playgroud)

这是因为您暂停了工作,这意味着它在您看不到它时什么也不做。您实际上也可以让作业在后台运行(通过输入bg)。有关详细信息,请参阅作业控制


小智 5

您可以用来fg恢复前台活动

或者

您可以使用bg将当前活动移至后台。