4 ms·
Modified to also record the elapsed times: # from https://news.ycombinator.com/item?id=7411120 export NOW_FORMAT='%F %T' export NOW_FORMAT2='+%Y-%m-%d %H
by dpatru 13y ago
Modified to also record the elapsed times:
# from https://news.ycombinator.com/item?id=7411120
export NOW_FORMAT='%F %T'
export NOW_FORMAT2='+%Y-%m-%d %H:%M:%S'
export NOW_FILE="$HOME/.now"
now() {
if [ -e $NOW_FILE ] &&
last_line=$(tail -n1 $NOW_FILE | cut -d " " -f 1,2) &&
time0=$(date -j -f "$NOW_FORMAT" "$(tail -n1 $NOW_FILE)" "+%s") &&
time1=$(date -j "+%s")
then echo "ET $(( $time1 - $time0 ))" >> $NOW_FILE
fi
echo $(date +"$NOW_FORMAT") - "$@" >> $NOW_FILE
tail $HOME/.now # show the last few lines
}