Memo Can
Memo Can

Reputation: 81

Syntax of redirection the stderr and stdout to dev/null

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!

Upvotes: 3

Views: 600

Answers (1)

Eugene Yarmash
Eugene Yarmash

Reputation: 149991

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'

Upvotes: 3

Related Questions