How to register shell script output as well as display on screen?

I am running a script called upgrade.sh

ANd upgrade.sh calls a script called roll.sh

roll.sh >> logfile.text 

But roll.sh has a few questions and tips, and redirection prevents these outputs from getting onto the screen. I can not edit roll.sh.

I also tried `results = $ (roll.sh)

Even then, the output did not appear on the screen.

+4
source share
3 answers

Use tee , it was created specifically for this purpose: forward standard input to the screen and one or more files. Be sure to use the -a option to add to logfile.text if you do not want to overwrite it.

 roll.sh | tee -a logfile.text 
+12
source

Do you want tee :

 TEE(1) User Commands TEE(1) NAME tee - read from standard input and write to standard output and files 
+1
source

A common way to handle this is that the script writes its requests to stderr instead of stdout.

+1
source

All Articles