Redirect output in Linux terminal

How to redirect output both to screen and file, separate stderr and stdout etc.

Linux shell has 3 file descriptors:

  1. stdin (0)
  2. stdout (1)
  3. stderr (2)

Redirect stderr andĀ stdoutĀ to file

Redirect stdout to file:

Redirect stderr to file:

Redirect both to the same file:

Redirect stdout and stderr to different files:

 

Redirect output to both file and screen

or

 

Leave a Reply

Your email address will not be published.