The tee command will read from standard input and write to standard output and files and can take the following flags:
-a, --append : append to the given FILEs, do not overwrite
-i, --ignore-interrupts : ignore interrupt signals
so, in effect, if you want to write to screen and file in one single line of code you can use the tee command to achieve this. An example of this is shown below where we will write "Hello world" to both the screen and a file.
[root@docker consul]# echo "hello world" | tee /tmp/world.txt hello world [root@docker consul]# cat /tmp/world.txt hello world [root@docker consul]#
The nice thing about the tee command is that this will work for all output which is send to stdout. Meaning, you can spool almost everything to a file and show it on the screen at the same time.