在后台运行的bash命令,而无需打印的作业和进程ID [英] Running bash commands in the background without printing job and process ids

查看:96
本文介绍了在后台运行的bash命令,而无需打印的作业和进程ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在bash中后台运行的过程是相当容易的。

To run a process in the background in bash is fairly easy.

$ echo "Hello I'm a background task" &
[1] 2076
Hello I'm a background task
[1]+  Done                    echo "Hello I'm a background task"

然而其输出是详细。在第一行打印作业ID和后台任务的进程的ID,那么我们有命令的输出,最后我们的作业ID,其地位和由此引发作业的命令。

However the output is verbose. On the first line is printed the job id and process id of the background task, then we have the output of the command, finally we have the job id, its status and the command which triggered the job.

有没有办法用晚餐preSS运行的后台任务这样的输出,输出看上去完全,因为它会不会在最后的符号?即:

Is there a way to suppress the output of running a background task such that the output looks exactly as it would without the ampersand at the end? I.e:

$ echo "Hello I'm a background task" &
Hello I'm a background task

我想问的原因是,我想运行一个后台进程为制表完成命令的一部分,这样命令的输出必须是不间断的,以任何意义。

The reason I ask is that I want to run a background process as part of a tab-completion command so the output of that command must be uninterrupted to make any sense.

推荐答案

不关完成,但你可以肃preSS通过将呼叫子shell的输出:

Not related to completion, but you could supress that output by putting the call in a subshell:

(echo "Hello I'm a background task" &)

这篇关于在后台运行的bash命令,而无需打印的作业和进程ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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