unix linux

unix linux shell script code snippet

Generating script logs with timestamp Just as the duration of script it’s useful to have time-stampped log. Use following function to log time for every output. {% highlight javascript %} log() { echo [date +%Y-%m-%d\ %H:%M:%S] $* } {% endhighlight %}