I want to redirect both stdout and stderr of a process to a single file. How do I do that in Bash?
For situation, when "piping" is necessary you can use :
|&
For example:
echo -ne "15\n100\n"|sort -c |& tee >sort_result.txt
or
TIMEFORMAT=%R;for i in `seq 1 20` ; do time kubectl get pods |grep node >>js.log ; done |& sort -h
This bash-based solutions can pipe STDOUT and STDERR separately (from STDERR of "sort -c" or from STDERR to "sort -h").