stdin
).stdout
).stderr
).Example redirection(s)…
docker ps 1> /dev/null 2>&1
The above example will redirect stdout
(1) to /dev/null
.
It then redirects stderr
(2) to wherever stdout
is pointing.
At first, 2>1
may look like a good way to redirect stderr
to stdout
. However, it will actually be interpreted as “redirect stderr to a file named 1”. &
indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1
.