In the lesson on basic file-descriptors (04-pipes) you already saw
>, >>, and |. Here are five idioms that show up in any serious
bash script and somehow rarely get explained together:
2>and2>&1: working with stderr separatelytee: write to a file and keep the pipeline going<(cmd): process substitution, a command as a file- here-doc and here-string: data right in the script
exec N>file: custom FDs for long-running logs
All of these operators work by manipulating the process's integer file
descriptors. There are three by default: 0 (stdin), 1 (stdout),
2 (stderr). The redirect 2>file means "open file and make it fd=2
for the command".