Bash - Echo on the console and in a logfile in the same time
In my previous article Bash - Script to add logging features to your script, I've shared a way to write information in a logfile.
By running ls -alh /tmp
you will get the list of all files in the /tmp
folder and display the list on your console. By running ls -alh /tmp >> application.log
you won't see the list in your console since everything will be written in the application.log
file.
How can we display the output of a command like ls
f.i. both on the console and in a logfile?