Standard Output (stdout)
To redirect stdout to a file, use the > operator:
To append stdout to a file, use the >> operator:
Standard Error (stderr)
To redirect stderr to a file, use the 2> operator:
Redirecting stdout and stderr Separately
To redirect stdout and stderr to separate files:
Redirecting stdout and stderr to the Same File
To redirect both stdout and stderr to the same file:
Here, 2>&1 means “redirect stderr (2) to the same location as stdout (1)”.
Or even simpler, as it does the same thing: