bash: input and output to files

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

Redirect stdout to file:

script.sh > file.txt

Append stdout to file:

script.sh >> file.txt

Redirect both stdout and stderr to file:

script.sh &> file.txt

Append both stdout and stderr to file:

script.sh >> file.txt 2>&1