This question already has an answer here:
I've a bash script that call various commands and prints some output (both from the called commands themselves, such as
git pull, and informative messages generated by the script itself such as
Operation took XX minutes.
I'd like to capture the whole output to a file from the script itself: basically I'm trying to avoid the need to call the
./myscript.sh > file.txt for non-relevant-here reasons.
Basically I'd like to do something like this:
startCapture git pull echo "Text" other-command endCapture
Plus, I also require the output to be printed on my shell while the script is running.
The final goal is to:
./myscript.shwithout additional shell construct
- see the output on the terminal as I do now
- obtain file on disk with the whole output
Is this even possible?