Bash脚本,错误输出重定向

时间:2014-10-30 03:43:01

标签: bash shell redirect error-handling

我想重定向错误

python: can't open file '/usr/bin/file': [Errno 2] No such file or directory

我使用了这个命令

python /usr/bin/file 2> /dev/zero

但是这隐藏了我文件中的所有输出,所以我只想重定向未找到的错误而没有别的。

二进制文件由我编写,通过python给出这个

Enter your password:
Welcome User :)
Checking your Secure Code now ...
Secure Code OK , Enjoy !!

What is the folder path ? ### This is hidden when used the code ###

1 个答案:

答案 0 :(得分:1)

你想要/dev/null,而不是/dev/zero,它是脚本的生成器(如果你需要的话,你可以读取无穷无尽的零字节流)。

您显示的语法实际上只重定向标准错误;如果标准输出丢失,那是因为其他原因。