Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 795
avasin Avatar asked Aug 31 '12 08:08

avasin


1 Answers

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
like image 158
cnicutar Avatar answered Sep 23 '22 00:09

cnicutar