How to Use Pipes and Redirection in Linux
Pipes and redirection are fundamental Linux concepts that let you chain commands together and control where output goes. Mastering these tools makes you far more productive when managing your Breeze from the command line.
Output Redirection
# Redirect stdout to a file (overwrite)
ls /var/www > files.txt
# Append stdout to a file
echo "new entry" >> /var/log/app.log
# Redirect stderr to a file
nginx -t 2> /tmp/errors.log
# Redirect both stdout and stderr
command > output.log 2>&1
Input Redirection
# Feed a file as input
mysql -u root < backup.sql
# Here document for inline input
cat <<EOF > /etc/motd
Welcome to your Breeze server
Unauthorized access is prohibited
EOF
Pipes
The pipe operator | sends one command's output as input to the next:
# Find large log files
du -sh /var/log/* | sort -rh | head -10
# Count active connections
ss -tuln | grep LISTEN | wc -l
# Search and filter processes
ps aux | grep nginx | grep -v grep
# Extract unique IPs from access log
awk '{print $1}' /var/log/nginx/access.log | sort -u | wc -l
Useful Combinations
tee— write to file AND stdout:command | tee output.logxargs— convert stdin to arguments:find . -name "*.log" | xargs rm/dev/null— discard output:command > /dev/null 2>&1
Combining pipes and redirection lets you build powerful one-liners for monitoring, log analysis, and automation on your Breeze.