How to redirect stdout only?

To redirect only the standard output (stdout) to a file while keeping the standard error (stderr) unchanged, you can use the following syntax:

command > output.txt

In this command:

  • command is the command you want to run.
  • > is the redirection operator.
  • output.txt is the file where you want to redirect the standard output.

This will redirect only the stdout of command to output.txt, while any error messages (stderr) will still be displayed in the terminal.

If you want to append the output instead of overwriting the file, you can use >>:

command >> output.txt

0 Comments

no data
Be the first to share your comment!