0

I'm running this line on my shell script

sudo npm install -g yaml-cli -y 2>&1 >/dev/null

I would expect to get no output, but I still get

npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
0

Redirections are evaluated from left to right, you have got this other way around. Just swap the redirections:

sudo npm install -g yaml-cli -y >/dev/null 2>&1

In sudo npm install -g yaml-cli -y 2>&1 >/dev/null:

  • First, for 2>&1, the STDERR (FD 2) is being sent to the terminal (precisely, where the STDOUT (FD 1) is currently attached to, presumably terminal), so the errors are being shown

  • Then, for >/dev/null, the STDOUT is being sent to /dev/null, this happens later

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