Zest.

Bash: Redirect output and pipes

A short, tested Bash example for redirect output and pipes. Copy it and adjust the names and paths for your project.

Bash
cmd > out.txt          # overwrite
cmd >> out.txt         # append
cmd 2> err.txt         # errors only
cmd > all.txt 2>&1     # both
cmd > /dev/null 2>&1   # discard everything
cmd | tee out.txt      # show and save

Find it in Zest

Search for “bash redirect output and pipes” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Bash examples

All Bash examples