Reputation: 4028
Is it possible for me to cut these two lines of shell script into one line.
My two lines of code echo the same string but one goes into the Console and the other into a log file.
echo "Starting scriptr" `date '+%T'` >> script.log
echo "Starting script" `date '+%T'`
Thanks
Upvotes: 2
Views: 2443
Reputation: 123608
Use tee
:
echo "Starting scriptr" `date '+%T'` | tee script.log
In order to append to the log file, say tee -a
Quoting from man tee
:
tee - read from standard input and write to standard output and files
Upvotes: 5