The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 50,611β€…    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: April 8, 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:

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:

⇧ Why combine commands on a single line in a Bash script? Ubuntu 19.10 - Night Mode does not change the color on screen  β‡©