#!/usr/bin/env ksh
# @(#) s1 Demonstrate date arithmetic with ksh printf.
# Utility functions: print-as-echo, print-line-with-visual-space, debug.
# export PATH="/usr/local/bin:/usr/bin:/bin"
LC_ALL=C ; LANG=C ; export LC_ALL LANG
pe() { for _i;do printf "%s" "$_i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }
em() { pe "$*" >&2 ; }
db() { ( printf " db, ";for _i;do printf "%s" "$_i";done;printf "\n" ) >&2 ; }
db() { : ; }
# C=$HOME/bin/context && [ -f $C ] && . $C
version =o version
echo ksh - ${.sh.version}
# %Y%m%d%H%M . [ex: 201609140905]
pl " Results, today:"
printf "%(%Y%m%d%H%M)T\n" now
pl " Results, 2 days ago:"
printf "%(%Y%m%d%H%M)T\n" "2 days ago"
pl " Results, almost any time:"
arbitrary_date=201409140905
printf "%(%Y%m%d%H%M)T\n" "$arbitrary_date"
pl " Results, 2 days before almost anytime:"
printf "%(%Y%m%d%H%M)T\n" "$arbitrary_date 2 days ago"
exit 0
producing:
$ ./s1
OS, ker|rel, machine: SunOS, 5.11, i86pc
Distribution : Solaris 11.3 X86
version (local) 1.77
ksh - Version JM 93u 2011-02-08
-----
Results, today:
201609140747
-----
Results, 2 days ago:
201609120747
-----
Results, almost any time:
201409140905
-----
Results, 2 days before almost anytime:
201409120905
See man pages or Google search results for details.
Modern solaris ought to have GNU date somewhere, either as gdate or buried under /usr/gnu/bin/ or something but a lot of installers seem to have bypassed it somehow.
If you have perl, you can use my generic date script which emulates some of GNU date's -d feature.
Solaris 11.3 has gnu date as gdate mostly by default.
By default i mean someone takes text install, it will get solaris-small-server group package which includes a lot of gnu utilites.
This kind of answer really frustrates the person asking the question. it's not constructive and doesn't really aid in solving the issue. I'm sure a lot of our questions can be answered similarly but doesn't give an immediate solution.
---------- Post updated at 12:21 PM ---------- Previous update was at 12:14 PM ----------
are you working comparing files based on a timestamp?
[ FILE1 -nt FILE2 ] True if FILE1 has been changed more recently than FILE2, or if FILE1 exists and FILE2 does not.
[ FILE1 -ot FILE2 ] True if FILE1 is older than FILE2, or is FILE2 exists and FILE1 does not.
[ FILE1 -ef FILE2 ] True if FILE1 and FILE2 refer to the same device and inode numbers.
The reason for such an answer is to encourage the OP to come up with a solution instead of having others write it for them...the forumites are here to help but dont expect us to spoon feed others...