2

I want to redirect the stderr and stdout to dev/null. Which ist the correct way to redirect and is there difference betweent these options? I have seen in internet two syntax:

  1. command &>/dev/null (without space)

  2. command &> /dev/null (with space)

Thanks in advance!

Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
Memo Can
  • 61
  • 1
  • 4

1 Answers1

3

Bash allows spaces around a redirection operator, so both forms are valid.

That said, you can't use spaces between parts of more complex redirection operators, e.g:

command 2> /dev/null   # ok
command 2 > /dev/null  # wrong, the operator is '2>'
command 2> &1          # wrong, the operator is '2>&1'
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378