rinku
February 26, 2008, 11:10pm
1
I want to calculate the date of next satureday of current date using shell script.
Suppose, today is 27-feb-08
I want to get the date of next satureday, which means 01-mar-08, in the formate '' YYMMDD ".
I do this in ksh..
Please tell me any type of command which help me out.
Thanks in advance...
Ygor
February 27, 2008, 7:40pm
2
Got gnu date?
$ date -d 'next sat' '+%y%m%d'
080301
The date -d option is not working for me...
I want to find the future date i.e. next monday.
The date format be anything just need to have a validation check for my application program. Help me on this.
Ygor
September 2, 2008, 11:05pm
4
Try this function...
#!/usr/bin/ksh
function dayshift {
perl -e '@f = localtime(time+(86400*$ARGV[0]));
printf "%04d%02d%02d\n", $f[5]+1900, $f[4]+1, $f[3];' -- $1
}
NEXT_MONDAY=$(dayshift $((8-$(date '+%u'))))
...format is YYYYMMDD, but change the printf if you want.