IO Redirection
Overview
- stdin - keyboard
- stout - screen
- stderr - error outputs
Output redirection
ls -al > listing
echo "This is a test" >> /var/log/messages
Input redirection
sort < listing
sort < listing > sorted_list
Pipes
ls -l | less # only outputs one screen at a time
du | sort -nr
ls -l | wc -l
tar -tzvf tarfile/tgz | less
Error redirection
myscript.sh 2> errors # redirects stderr rather than stdout
myscript.sh > allout.txt 2>&1 # redirects stdout and stderr to file