3 ms·
`2>&1 > /dev/null` will drop stdout and write stderr to stdout. `> /dev/null 2>&1` will drop both stdout and stderr. For myself, with `which` I would just use
by chrismorgan 13y ago
`2>&1 > /dev/null` will drop stdout and write stderr to stdout.
`> /dev/null 2>&1` will drop both stdout and stderr.
For myself, with `which` I would just use `> /dev/null`, as `which` writes to stdout and not stderr: if anything comes through stderr, you probably want to know about it.
- arek2 13y agoAll right, but he wrote: "The 2>&1 > /dev/null puts both output stream and error stream to /dev/null (which means nothing printed on console).". So the intention was different. PS. I think "which" will never produce anything on stderr
- fizerkhan 13y agoAs Chris said, `2>&1 > /dev/null` will drop stdout and write stderr to stdout. If you do not want anything to printed on console, you can use it. Now only i came to know that `which` never produce the stderr. So it is enough to use `>/dev/null`.