Redirect the standard error to the standard output

Posted on
To redirect the standard error of a shell command, just use the following syntax:
ls file-that-does-not-exist 2>&1 | grep file
Or even better not to have on the terminal the standard error just throw it in /dev/null
ls file-that-does-not-exist 2>/dev/null
The standard open or standard streams that are automatically opened are:
  • 0 standard input
  • 1 standard output
  • 2 standard error

Leave a Reply

Your email address will not be published. Required fields are marked *