Just noting that if you wish to redirect both stderr and stdout to a file while you have noclobber set (i.e. set -o noclobber
), you can use the code:
cmd >| file.txt 2>&1
More information about this can be seen at https://stackoverflow.com/a/876242.
Also this answer's @TuBui's question on the answer @BrDaHa provided above at Aug 9 '18 at 9:34.