Better ‘date’ Functionality in Solaris
The Solaris date command does not have many of the useful features of its GNU equivalent. A workaround is to use Tcl. This requires tclsh to be installed (which tclsh). You can implement this workaround as a function:
tcldate() {
d=${1:-now} # input date string
f=${2:-%c} # output date format
echo "puts [clock format [clock scan {$d}] -format {$f}]" | tclsh
}Or as a script (
ln -s /var/adm/bin/tcldate.sh /usr/bin/tcldate):#!/bin/bash
tcldate() {
d=${1:-now} # input date string
f=${2:-%c} # output date format
echo "puts [clock format [clock scan {$d}] -format {$f}]" | tclsh
}
tcldate "$1" "$2"Some examples:
# date ; tcldate "`date`+1month+12days+17hours+12minutes+30seconds" "%Y-%m-%d %H:%M:%S" Tuesday, June 28, 2016 08:52:39 AM EDT 2016-08-10 02:05:09
