I'm using Amazon Linux and writing a script in bash. I want to output both stderr / stdout (preferably in the order that they occur) to a file as well as the console. However, this command isn't working ...
node test.js 2>&1 >> /tmp/output | tee --append /tmp/output
The output gets sent to the file, but it is not getting output to the console as it is happening. How can I correct the above to view the output?
tee
s to get output to terminal-screen and/or write/append to files before the final redirection. If you had a long pipeline with many commands, you would use redirection (>) to save the final result to a file. But you could usetee
s to also save several of the intermediate results to files... and/or to print one of the intermediate - or the final result - to the terminal-screen.