What does “1>&2” mean in bash? [duplicate]

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

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

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

I use MacOS X. My bash script is:

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

1 Answer

It outputs the message to stderr. Therefore 1>&2 means redirect stdout to stderr.

You Might Also Like