bash pipes redirection command-line
Pipes and Redirection
The pipe `|` sends one command's output to another command's input. Redirection `>` sends output to a file.
This is the Unix philosophy in action: small tools that do one thing well, chained together.
bash
# Pipe: send output to another command
cat file.txt | grep "error" | wc -l
# Redirect output to a file (overwrites)
echo "hello" > file.txt
# Append to a file
echo "world" >> file.txt
# Redirect errors separately
command 2> errors.log
# Redirect both stdout and stderr
command > output.log 2>&1