正确打印错误消息的方法 [英] Proper way of printing out an error message

查看:66
本文介绍了正确打印错误消息的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这行是在Bash中打印错误消息的最佳方法吗?

Is this line the best way to print out an error message in Bash?

echo 'Error: banana' >&2

我需要更新数十种使用所有不同方式记录错误的Bash脚本,我不妨选择正确"的方法来做到这一点,并遵循我所遵循的标准...

I need to update tens of Bash scripts which use all different ways of logging errors and I might as well choose the "right" way to do this and adhere to a standard as I do it...

推荐答案

在linux上,我更愿意说

On linux, I'd prefer to say

echo "Some error message" >> /dev/stderr

由于/dev/stderr 符号链接到/proc/$ PID/fd/2

这篇关于正确打印错误消息的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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