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

查看:24
本文介绍了一个接一个地运行一个命令,即使我挂起第一个命令(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天全站免登陆