Unix HowTo: Date substraction addition in UNIX
This is done using perl code snippet.
$ cat dateSubs.sh
TODAYS_DATE=`date|cut -d" " -f2,3,6|sed 's/ /-/g'`
a=`perl -e 'printf "%s", scalar localtime(time-604800)'`
WEEKS_BEFORE=`echo $a|cut -d" " -f2,3,5|sed 's/ /-/g'`
echo "TODAYS_DATE : $TODAYS_DATE"
echo "WEEKS_BEFORE: $WEEKS_BEFORE"
Result:-
$ dateSubs.sh
TODAYS_DATE : Oct-17-2007
WEEKS_BEFORE: Oct-10-2007
---: I am not responsible for any damages happened from the suggestion of my blog :---
Reach me at : m.a.hasim@inbox.com
Labels: Technical_HowTo_Unix
0 Comments:
Post a Comment
<< Home