使用bash脚本,我怎么能燮preSS从命令所有输出? [英] With Bash Scripting, how can I suppress all output from a command?

查看:248
本文介绍了使用bash脚本,我怎么能燮preSS从命令所有输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行带有参数的程序bash脚本。该程序可以输出一些状态(这样做,这样做...)。没有选择该程序要安静。我怎样才能prevent的脚本显示任何内容?

I have a bash script that runs a program with parameters. That program outputs some status (doing this, doing that...). There is no option for this program to be quiet. How can I prevent the script from displaying anything?

我在寻找类似Windows的回声关。

I am looking for something like windows "echo off".

推荐答案

以下发送标准输出到空设备(位桶)。

The following sends standard output to the null device (bit bucket).

scriptname >/dev/null

如果你也想的错误消息被派往那里,用一个(第一个可能并不适用于所有的炮弹工作):

and if you also want error messages to be sent there, use one of (the first may not work in all shells):

scriptname &>/dev/null
scriptname >/dev/null 2>&1
scriptname >/dev/null 2>/dev/null

,如果你想记录的消息,但是没有看到他们,用实际文件替换的/ dev / null的,如:

scriptname &>scriptname.out

有关完整性,在Windows cmd.exe的(其中NUL是的/ dev /空的等价物),它是:

For completeness, under Windows cmd.exe (where "nul" is the equivalent of "/dev/null"), it is :

scriptname >nul 2>nul

这篇关于使用bash脚本,我怎么能燮preSS从命令所有输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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