$ foobar
sh: foobar: not found
$ foobar 2>/dev/null
$ 我尝试只重定向foobar的stderr (如果foobar存在并且可以运行),但是shell的错误消息也被重定向。这发生在bash、ksh和sh中,但不会发生在csh中。我不熟悉bourne shell源代码,但我猜这是因为shell首先派生,然后重定向,然后尝试exec(),当exec()失败时,它会向已经重定向的stderr发送错误消息。
发布于 2012-10-09 00:21:55
如果foobar是某个可执行文件,请尝试:-
$ ./foobar
sh: foobar: not found
$ ./foobar 2>/dev/null #alternatively you can use full path.
$ https://stackoverflow.com/questions/12785533
复制相似问题