echo >&2“一些文本"它在 shell 脚本中是什么意思 [英] echo >&2 "some text" what does it mean in shell scripting

查看:26
本文介绍了echo >&2“一些文本"它在 shell 脚本中是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到 echo 在很多地方被这样使用:

I have seen echo being used like this in many places:

echo >&2 message text ...

这是什么意思?

我理解2>&1,但是,我不知道如何解释上面的用法.

I understand 2>&1, however, I am not sure how to interpret the usage above.

谁能解释一下?

推荐答案

快速解释其他人遗漏的内容:

To quickly explain what the others missed:

echo "hey" >&2

> 重定向标准输出(隐式 1>)

> redirect standard output (implicit 1>)

& 接下来是文件描述符,而不是文件(仅适用于 > 的右侧)

& what comes next is a file descriptor, not a file (only for right hand side of >)

2 stderr 文件描述符编号

2 stderr file descriptor number

stdoutecho 命令重定向到 stderr.(如果您要使用echo "hey" >2,您会将hey 输出到名为2 的文件中)

Redirect stdout from echo command to stderr. (If you were to useecho "hey" >2 you would output hey to a file called 2)

这篇关于echo >&2“一些文本"它在 shell 脚本中是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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