如何将所有输出重定向到/ dev / null的 [英] How to redirect all output to /dev/null

查看:175
本文介绍了如何将所有输出重定向到/ dev / null的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在后台运行一个程序(谷歌铬),但是从输出任何消息到终端prevent它。

I want to run a program (google-chrome) in the background, but prevent it from outputting any messages to the terminal.

我试着这样做:

google-chrome 2>&1 1>/dev/null &

然而,终端还填补了没有像信息[5746:5746:0802/100534:ERROR:object_proxy.cc(532)未能调用方法:org.chromium.Mtpd.EnumerateStorag。 ..

我是什么做错了吗?我怎么所有的输出重定向到/ dev / null的?

What am I doing wrong? How do I redirect ALL the output to /dev/null?

推荐答案

重定向操作符是从左向右。你做错了什么是放2>&安培; 1首,这点2相同的地方为1目前是指向这是本地终端屏幕上,因为你没有重定向1呢。你需要做的是以下任一操作:

redirection operators are evaluated left-to-right. what you did wrong was put 2>&1 first, which points "2" to the same place as "1 currently is pointed to" which is the local terminal screen because you have not redirected 1 yet. What you need to do is either of the following:

2>/dev/null 1>/dev/null google-chrome &

2>/dev/null 1>&2 google-chrome &

重定向运营商的有关该命令的位置并不重要。你可以之前或命令后,把它们。

the placement of the redirect operators in relation to the command does not matter. you can put them before or after the command.

这篇关于如何将所有输出重定向到/ dev / null的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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