CS-FreeStyle / 10000-How-To-Do-in-CS

1 stars 0 forks source link

output text to both screen and file inside a shell script? #113

Open liuty10 opened 4 years ago

liuty10 commented 4 years ago

https://unix.stackexchange.com/questions/80707/how-to-output-text-to-both-screen-and-file-inside-a-shell-script

command | tee -a "$log_file" tee saves input to a file (use -a to append rather than overwrite), and copies the input to standard output as well.

update-client 2>&1 | tee my.log 2>&1 redirects standard error to standard output, and tee sends its standard input to standard output and the file.