Published on

What does the `2>` mean on the Unix command-line?

scriptlist=`ls $directory_/fallback_* 2> /dev/null`

File descriptor 2 represents standard error. (other special file descriptors include 0 for standard input and 1 for standard output).

2> /dev/null means to redirect standard error to /dev/null. /dev/null is a special device that discards everything that is written to it.

Putting all together, this line of code stores the standard output of command ls $directory_/fallback_* 2> /dev/null into the variable scriptlist, and the standard error is discarded.

Reference