Redirection Operators Explained
Redirection Operators Explained
# Overwrite stdout: >
echo "text" > file.txt
# Append stdout: >>
echo "text" >> file.txt
# Redirect stderr to stdout: 2>&1
command > output.log 2>&1
# Bash shorthand redirect both stdout and stderr: &>
command &> output.log
# Read stdin from file: <
grep "root" < /etc/passwd
# Open file for read/write on FD: <>
exec 3<> /tmp/scratch.dat