bash中的"1& 2"是什么意思? [英] What does “1>&2” mean in bash?

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

问题描述

bash脚本中的"1>& 2"是什么意思?

What does "1>&2" mean in a bash script?

例如,bash脚本的以下行是做什么的?

For instance, what does the following line from a bash script do?

echo "$1 is not a directory!" 1>&2

我使用Mac OSX.我的bash脚本是:

I use mac os x. My bash script is:

if [ ! -d $1 ]; then
    echo "$1 is not a directory" 1>&2
    exit 1
fi

推荐答案

它将消息输出到stderr."1>& 2"表示将标准输出重定向到标准错误. http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html

It outputs the message to stderr. "1>&2" means redirect stdout to stderr. http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html

这篇关于bash中的"1& 2"是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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