Views:
55,374β
Votes: 11β
Tags:
command-line
bash
redirect
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1182458
Title:
What does >&2 mean in a shell script?
ID:
/2019/10/20/What-does-__2-mean-in-a-shell-script_
Created:
October 20, 2019
Edited: October 26, 2019
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
It is simply displaying the message β/blah/blah/: Is directory
β to stderr
. Also known as Standard Error which is denoted by &2
.
Without the &2
messages are displayed on stdout
. Also known as Standard Output which is denoted by &1
.
More details on displaying messages to &>2
can be found here:
- Bash command that prints a message on stderr
- echo >&2 βsome textβ what does it mean in shell scripting
In your command posted, both messages for stdout
and stderr
will appear on your terminal screen. However some applications will separate the stderr
messages and perform special processing.
Most people donβt bother redirecting echo
error messages to >&2
but it is technically the correct way of doing things.
For more reading on stdin
, stdout
and stderr
from user or system administrator perspective see:
For a programmers perspective of stdin, stdout, stderr which are &0, &1 and &2 respectively see: