Currently I have a shell script which logs messages to a log file like this:log_file=/some/dir/log_file.logecho some text >> $log_filedo_some_commandecho more text >> $log_filedo_other_commandWhen executing this script, there is no output to screen, and, since I'm connecting to the server via putty, I have to open another connection and do tail -f log_file_path.log, because I can't terminate the running script and I want to see the output in real time.Obviously, what I want is that the text messages are printed on screen and into file, but I'd like to do it in one line, not two lines, one of which has no redirection to file.How to achieve this?
how to output text to both screen and file inside a shell script?
shell;files;gnu screen;output
This works:command | tee -a $log_filetee saves input to a file (use -a to append rather than overwrite), and copies the input to standard output as well.