user433342
user433342

Reputation: 1050

Suppress warning output in bash

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

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

Upvotes: 3

Views: 17815

Answers (3)

Damian T.
Damian T.

Reputation: 332

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

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.

Upvotes: 6

konsolebox
konsolebox

Reputation: 75548

Try enclosing it on a subshell

( mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql ) &>/dev/null

Upvotes: 0

Gilles Quénot
Gilles Quénot

Reputation: 185530

Better give your exact code attempt and warnings in your original post, but if you try this one :

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

or

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

that should work.

Upvotes: 3

Related Questions