Automation · Bash Automation
Redirection
Cheat sheet · https://pcornel.dk/topic.php?topic=5283
Answer
Redirection in Bash sends output to files or other streams: > overwrite, >> append, 2> errors, &> both, and < for input, plus here-documents with << EOF for multi-line input.
Remember
- > overwrites and >> appends.
- 2> redirects errors and &> redirects both.
- Here-documents (<<EOF) feed multi-line input.
First checks
cmd > out.log 2>&1— stdout+stderr to filecmd 2>/dev/null— discard errors (deliberately)exec > >(tee -a log) 2>&1— log whole script
Verify in this order
command → fd redirection → file/pipe
Where it usually breaks
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5283