Syntax

Bash Redirect Output to a File Syntax

In Bash, redirect output to a file: writes (>) or appends (>>) output to a file — command > out.txt command >> out.txt

Quick Answer

Syntax
command > out.txt command >> out.txt
BashSyntax

Redirect Output to a File

Code example
command > out.txt command >> out.txt

Writes (>) or appends (>>) output to a file.

Learn More

How to redirect output to a file in Bash

  1. Open your Bash file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Bash Redirect Output to a File Syntax

Use command > out.txt command >> out.txt.

Related Syntax References

Frequently asked questions

What is the Bash syntax for redirect output to a file?

Use this pattern: command > out.txt command >> out.txt

Can I copy this Bash code example?

Yes. Use Copy code and adapt the example to your program.

Is this Bash syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify