Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

bash

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
like image 738
beginner Avatar asked Aug 04 '16 03:08

beginner


People also ask

What does 1 mean in a text?

Definition: Active or Top Partner (typically used in gay dating) Type: Cyber Term.

What does it mean to be #1?

1 : first in rank, importance, or influence : foremost cancer is the country's number one killer —often written No. 1. 2 : of highest or of high quality. Synonyms & Antonyms More Example Sentences Learn More About number one.

What does bring a +1 mean?

/ˌplʌs ˈwʌn/ a person that you take to a party or other event, usually when the invitation says that you can bring one other person with you: She asked Martin to be her plus one at the benefit. Inviting & summoning.


1 Answers

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

  • 3. All about redirection
like image 62
Robert Columbia Avatar answered Sep 25 '22 02:09

Robert Columbia