![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Time Between Dates | Sreejith_VK | Shell Programming and Scripting | 3 | 02-20-2008 01:06 AM |
| UNIX Dates | ndoggy020 | UNIX for Dummies Questions & Answers | 9 | 02-14-2008 06:25 PM |
| Select entries between two dates by converting Unix timestamp in Oracle Database. | amitsayshii | UNIX for Advanced & Expert Users | 1 | 08-08-2006 11:00 AM |
| How to compare two dates | bankpro | High Level Programming | 5 | 01-24-2006 04:07 AM |
| Unix dates | ssmiths001 | UNIX for Dummies Questions & Answers | 1 | 11-18-2004 10:45 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Need help with Unix dates
I'm very new to Unix, so forgive me for what will probably be a very quick fix. I have the following in a ksh script. Its purpose is to return yesterday's date. The $DAY part is coming back with a '2' but I need it to return as '02'. How can I do that?
date '+%b %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 } |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|