I wish to have one file output.txt
to hold all the outputs of my shell script. Similarly, a error.txt
file to hold all the errors of my shell script.
I understand that technically, I can achieve this by manually appending >>output.txt
to every line that prints out something. However, I feel that very ugly. I vaguely remember something like
#!/bin/sh
#$ -o ./output.txt
#$ -e ./error.txt
echo Hello World!
may work. However, it is somehow not working when I try it out.
So, how can I specify one output file that automatically absorbs all the outputs?
Update
This question may seem like a duplicate of this one. Yet, one difference is that I also wish to separate outputs and errors into two separate files.