bash - Bash脚本,错误输出重定向

标签 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 ###

最佳答案

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

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

关于bash - Bash脚本,错误输出重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26644694/

相关文章:

linux - oracle从plsql获取变量返回到linux

c# - 手动将 RedirectToRouteResult 解析为查看结果

asp.net - 使用登录控件登录应用程序后重定向到default.aspx而不是 "xxx.aspx"

json - 在不使用 perl 的情况下使用 sed、grep 或 awk 来复制正面回顾

bash - 如何获取第n个匹配的行号?

如果后跟管道,Linux tee 命令有时会失败

regex - 在 bash 中,如何检查数组中字符串的部分内容?

Linux bash读取输出解释

linux - 增加一个环境变量

php - 如何自动重定向到另一个传递一些数据的 PHP 脚本?