Use Input-output Redirection

General Information

Using input/output redirection (>, », |, 2>, etc.).


'>' Redirect standard output to a file, overwrite contents

cat /etc/system-release > info.txt


'»' Redirect standard output to file, append to file

tail /etc/passwd >> info.txt


'|' Piping output to other commands

cat /etc/passwd | wc -l


'2>' Redirect standard error

ssh admin@webserver01.com "uptime" 2>/dev/null


Redirect both standard error and standard output

ssh admin@webserver01.com "uptime" &> results.log


Redirect standard error to standard out

cat /etc/system-release /etc/Red 2>&1 | grep Red