We’re rewarding the question askers & reputations are being recalculated! Read more.
3 I propose removing the paragraph shown; since it refers to a submission typo that's since been corrected, it has no significance, and though accurate, does not improve the answer.
source | link

You're thinking of 2>, not >2. Or, perhaps, you're thinking of >&2. The example you give, echo error >2, will just create a regular file called 2 with the string error\n in it.

In bash, and other shells, the way to redirect something to standard error is to use >&2. Bash opens /dev/stderr as the file descriptor 2. File descriptors are referenced by &N where N is the number of the descriptor. So, echo error >&2 will print error to standard error, to /dev/stderr.

It will also open /dev/stdout as file descriptor 1. This means you can do echo output >&1. However, since everything is printed to standard output anyway by default, that is the same as echo output by itself.

Now, 2> is different. Here, you are redirecting the error output of a command somewhere else. So, 2>file means "redirect anything printed to file descriptor 2 (standard error) to file".

You're thinking of 2>, not >2. Or, perhaps, you're thinking of >&2. The example you give, echo error >2, will just create a regular file called 2 with the string error\n in it.

In bash, and other shells, the way to redirect something to standard error is to use >&2. Bash opens /dev/stderr as the file descriptor 2. File descriptors are referenced by &N where N is the number of the descriptor. So, echo error >&2 will print error to standard error, to /dev/stderr.

It will also open /dev/stdout as file descriptor 1. This means you can do echo output >&1. However, since everything is printed to standard output anyway by default, that is the same as echo output by itself.

Now, 2> is different. Here, you are redirecting the error output of a command somewhere else. So, 2>file means "redirect anything printed to file descriptor 2 (standard error) to file".

In bash, and other shells, the way to redirect something to standard error is to use >&2. Bash opens /dev/stderr as the file descriptor 2. File descriptors are referenced by &N where N is the number of the descriptor. So, echo error >&2 will print error to standard error, to /dev/stderr.

It will also open /dev/stdout as file descriptor 1. This means you can do echo output >&1. However, since everything is printed to standard output anyway by default, that is the same as echo output by itself.

Now, 2> is different. Here, you are redirecting the error output of a command somewhere else. So, 2>file means "redirect anything printed to file descriptor 2 (standard error) to file".

2 added 1 character in body
source | link

You're thinking of 2>, not >2. Or, perhaps, you're thinking of >&2. The example you give, echo error >2, will just create a regular file called 2 with the string error\n in it.

In bash, and other shells, the way to redirect something to standard error is to use >&2. Bash opens /dev/stderr as the file descriptor 2. File descriptors are referenced by &N where N is the number of the descriptor. So, echo error >&2 will print error to standard error, to /dev/stderr.

It will also open /dev/stdout as file descriptor 1. This means you can do echo output >&1. However, since everything is printed to standard output anyway by default, that is the same as echo output by itself.

Now, 2> is different. Here, you are redirecting the error output of a command somewhere else. So, 2>file means "redirect anything printed to file descriptor 2 (standard error) to file".

You're thinking of 2>, not >2. Or, perhaps, you're thinking of >&2. The example you give, echo error >2, will just create a regular file called 2 with the string error\n in it.

In bash, and other shells, the way to redirect something to standard error is to use >&2. Bash opens /dev/stderr as the file descriptor 2. File descriptors are referenced by &N where N is the number of the descriptor. So, echo error >&2 will print error to standard error, to /dev/stderr.

It will also open /dev/stdout as file descriptor 1. This means you can do echo output >&1. However, since everything is printed to standard output anyway by default, that is the same as echo output by itself.

Now, 2> is different. Here, you are redirecting the error output of a command somewhere else. So, 2>file means "redirect anything printed to file descriptor 2 (standard error) to file.

You're thinking of 2>, not >2. Or, perhaps, you're thinking of >&2. The example you give, echo error >2, will just create a regular file called 2 with the string error\n in it.

In bash, and other shells, the way to redirect something to standard error is to use >&2. Bash opens /dev/stderr as the file descriptor 2. File descriptors are referenced by &N where N is the number of the descriptor. So, echo error >&2 will print error to standard error, to /dev/stderr.

It will also open /dev/stdout as file descriptor 1. This means you can do echo output >&1. However, since everything is printed to standard output anyway by default, that is the same as echo output by itself.

Now, 2> is different. Here, you are redirecting the error output of a command somewhere else. So, 2>file means "redirect anything printed to file descriptor 2 (standard error) to file".

1
source | link

You're thinking of 2>, not >2. Or, perhaps, you're thinking of >&2. The example you give, echo error >2, will just create a regular file called 2 with the string error\n in it.

In bash, and other shells, the way to redirect something to standard error is to use >&2. Bash opens /dev/stderr as the file descriptor 2. File descriptors are referenced by &N where N is the number of the descriptor. So, echo error >&2 will print error to standard error, to /dev/stderr.

It will also open /dev/stdout as file descriptor 1. This means you can do echo output >&1. However, since everything is printed to standard output anyway by default, that is the same as echo output by itself.

Now, 2> is different. Here, you are redirecting the error output of a command somewhere else. So, 2>file means "redirect anything printed to file descriptor 2 (standard error) to file.