How to output a text to both terminal and install.log

terminal

I want a few of my statements from my preinstall script to be visible to the user also (not just getting logged in install.log ) when my package is installed (via terminal).

Example : when my .pkg is called via the command "sudo installer -pkg /path/to/package -target /" , I want to print out "Thanks for installing my application" in the terminal itself

Best Answer

This is simple you can ua the following ways:

command | tee output.txt

The standard output stream will be copied to the file, it will still be visible in the terminal. If the file already exists, it gets overwritten. command | tee -a output.txt

The standard output stream will be copied to the file, it will still be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.

If you want any to know where I got this here is the reference:https://askubuntu.com/questions/420981/how-do-i-save-terminal-output-to-a-file/420983 @Byte Commamder.