have several commands in a shell file that I would like to log and show on screen. but some commands results I want to NOT show on screen and some I want to - but all of them need to be logged.
I can use tee or > or >> etc..
script.sh | tee -a logfile
but that does not allow me to pick and choose what shows on screen and what goes into logs.
example script - what I have now (each line is different and looks inefficient)
echo "setting date" | tee log.txt #show on screen and log
`date` | tee -a log.txt # screen and log
echo "setting name" | tee -a log.txt #show on screen
`who am i` >> log.txt | only log
I have a several commands like this - and am wondering if there is a efficient way to append to log AND/OR append to log while showing on screen.
OR do I have to modify and make a call in each line ?
Users will not be able to modify this script.