WRITELOOP

BASH TIPS

2018 March 22

OUTPUT REDIRECTION (STDOUT/STDERR)

Redirect STDOUT to file:

$ find /  -name foo > output.txt

Redirect error messages to nowhere:

$ find /  -name foo 2> /dev/null

Redirect both the error messages and the standard output to same file:

$ find / -name foo > output.txt 2>&1

OR

$ find / -name foo > output.txt 2> output.txt

Pipeing STDOUT and STRERR to another command:

find -name test.sh 2>&1 | tee /tmp/output2.txt