In my program, there will be a few seconds that the program writes data to a SSD that's not connected (i.e. writing to a empty bus host). As a result, there must be some I/O error messages output to the terminal during this time.
Besides writing the output to the terminal, I also need to record the progress of the program, but NOT the I/O error messages. The following is a snapshot of the error messages:
5-1Input/output error
Input/output error]! at block#[
]! at block#[Input/output error
WARNING: write errno[ 5
WARNING: write errno[ 5]! at block#[4773881Input/output error
Input/output error
146524727614844WARNING: write errno[ Input/output error
5]! at block#[], ret = ]! at block#[], ret = 13281183], ret = -1
WARNING: write errno[ Input/output errorWARNING: write errno[ 5]! at block#[234468], ret = -1-1
run.sh
$ run.sh | tee log.txt 2>&1
Here:
run.sh | tee log.txt 2>&1
You are redirecting the standard error of tee
to its standard output.
But this looks like it should be doing what you want (though the 2>&
is not needed) as tee does not generate error messages.
Try:
# run.sh output to log
# run.sh error to console
run.sh > log
# run.sh output to log and console
# run.sh error to console
run.sh | tee log
# run.sh error to same place as output
# run.sh output to console
run.sh 2>&1
# run.sh error to same place as output
# run.sh output to log
run.sh > log 2>&1
# run.sh error to same place as output
# run.sh output to console and log
run.sh 2>&1 | tee log