How to log output in bash and see it in the terminal at the same time?
Just use tail to watch the file as it's updated. Background your original process by adding & after your above command After you execute the command above just use
$ tail -f my.log
It will continuously update. (note it won't tell you when the file has finished running so you can output something to the log to tell you it finished. Ctrl-c to exit tail)
another option is to use block based output capture from within the script (not sure if that is the correct technical term).
Example
#!/bin/bash { echo "I will be sent to screen and file" ls ~} 2>&1 | tee -a /tmp/logfile.logecho "I will be sent to just terminal"
I like to have more control and flexibility - so I prefer this way.