How can I redirect the output of multiple commands at once?
To redirect stdout and stderr
date > file 2>&1
Redirecting an entire loop
for i in "${list[@]}"; do
echo "Now processing $i"
# more stuff here...
done > file 2>&1
Command grouping helps
{
date
# some other commands
echo done
} > messages.log 2>&1