Question: What does this do? I cannot find any information about what `&1` and `&2` are in `bash`.

```
$ echo "Hello" >&1
Hello

$ echo "Hello" >&2
Hello

$ echo "Hello" >&3
bash: syntax error near unexpected token `&'

```

I know that you can redirect standard and error output to a file, but what does the ampersand do in these cases?

Answer: 
`>&` is a variant on the `>` pipeline operation. While `>` redirects output into a named file (or the device's representation in the filesystem, such as `/dev/console`), `>&` redirects the output to one of the standard output streams. The most commonly used exaples are stream 1 (stdout) and stream 2 (stderr). Note that these are the same numbers you can use in front of the `>` or `>&` operators to say which stream's output you want to redirect.

`echo "hello" >&1` is redundant; you're redirecting stdout to stdout.
(`echo "hello" 1>&1` would mean the same thing, of course.)

A more interesting example: `echo "hello" 2>&1` redirects the echo command's error output from stderr to stdout, combining them into a single stream. This one is often useful if you want to run all the output through a single pipe rather than having them treated separately. `echo "hello" 2>&1 | tee log`, for example, captures a copy of both normal output and error messages into a single log file. 

BroSlow points out that, in version 4 and later of the `bash` shell, `|&` can be used as a shorthand for combining the streams, equivalent to `2>&1`. Good to know. (I still move between shells too frequently to have started using that one.)
```
1 is stdout Standard Out
2 is stderr Standard Error
& indicates that what follows is a file descriptor and not a filename ("fold a file descriptor into another")

```

common code is redirect stdderr to stdout

```
2>&1

```

then

```
mycommand 2>&1 1>logfile

```

or

```
mycommand > afile.txt 2>&1

```