即使我暂停第一个命令(Ctrl-z),也要一个接一个地运行命令 [英] Run one command after another, even if I suspend the first one (Ctrl-z)

查看:78
本文介绍了即使我暂停第一个命令(Ctrl-z),也要一个接一个地运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在bash中我可以通过用分号将它们分开来依次运行一个命令,例如

I know in bash I can run one command after another by separating them by semicolons, like

$ command1; command2

或者如果我只希望command2仅在command1成功的情况下运行,请使用&&:

Or if I only want command2 to run only if command1 succeeds, using &&:

$ command1 && command2

这有效,但是如果我使用Ctrl-z挂起command1,则在第一种情况下,它立即运行command2,在第二种情况下,它根本不运行.我如何才能依次运行命令,但仍然能够挂起第一个命令,但直到我重新启动它(使用fg)并完成后才可以运行第二个命令?我希望输入的内容尽可能简单,因为我希望以交互方式进行输入.也许我只需要在某个地方设置一个选项即可.

This works, but if I suspend command1 using Ctrl-z, in the first case, it runs command2 immediately, and in the second case, it doesn't run it at all. How can I run commands in sequence, but still be able to suspend the first command, but not have the second run until I have restarted it (with fg) and it finishes? I'd prefer something as simple to type as possible, as I would like to do this interactively. Or maybe I just need to set an option somewhere.

顺便问一下,Ctrl-z的正确用语是什么?

By the way, what is the proper term for what Ctrl-z does?

推荐答案

请执行以下操作:

(command1; command2)

请注意添加的括号.

这篇关于即使我暂停第一个命令(Ctrl-z),也要一个接一个地运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆