抑制bash中的警告输出 [英] Suppress warning output in bash

查看:174
本文介绍了抑制bash中的警告输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

我尝试添加2>/dev/null,&>/dev/null等,似乎没有什么可以抑制警告.

I tried adding 2>/dev/null, &>/dev/null, etc, nothing seemed to suppress the warnings.

推荐答案

mysql_tzinfo_to_sql /usr/share/zoneinfo 2>/dev/null | mysql -u root mysql

将错误输出到STDERR的命令是第一个命令,而不是第二个命令.将STDERR重定向放在管道之前,这应该可以解决您的问题.

The command that is producing the error output to STDERR is the first command, not the second one. Put the STDERR redirection before the pipe, and this should fix your problem.

这篇关于抑制bash中的警告输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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