Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Yestreday's date

Status
Not open for further replies.

Zakk

MIS
Mar 28, 2002
10
US
Hi friends!

Does anybody get a shell script which produces yesterday's date (e.g. even if today is 1st January ... and next: what about February ...?) and will be so kind to send it on the forum?
Thank you.

Zakk (NotWild)
 
#!/usr/bin/ksh
date '+%m %d %Y' |
{
read MONTH DAY YEAR
DAY=`expr "$DAY" - 1`
case "$DAY" in
0)
MONTH=`expr "$MONTH" - 1`
case "$MONTH" in
0)
MONTH=12
YEAR=`expr "$YEAR" - 1`
;;
esac
DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
esac
echo "Yesterday was: $MONTH $DAY $YEAR"
}
 
A lot of thanks for your kind help. Your script looks so terribly :) easy ... because being really great.
Shame on me while still being not able to write such a genius things ... :-(

Have a nice and successful day.

Happy Zakk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top