12

In bash we have 3 stream types:

  • 0 (STDIN)
  • 1 (STDOUT)
  • 2 (STDERR)

So, while executing some program i can use these streams (e.g. i can redirect them from console to a file or smth like /dev/null, etc):

# only errors from STDERR will be shown, STDOUT will be moved to /dev/null
command > /dev/null
# only STDOUT will be shown, STDERR will be moved to /dev/null
command 2> /dev/null

I saw that some people write command &> /dev/null

What is the difference between > and &> in bash?

1 Answer 1

16

what is the difference between ">" and "&>" in bash?

It's a bashism that redirects both stdout and stderr. It can also be achieved with the more portable:

command > file 2>&1

Not the answer you're looking for? Browse other questions tagged or ask your own question.