![]() |
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 Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sysdate -1 in unix | kskywr | UNIX for Dummies Questions & Answers | 1 | 04-12-2007 12:53 PM |
| sysdate -p -f%d/%m/%Y | abu_hassan | UNIX for Dummies Questions & Answers | 1 | 02-11-2007 12:26 PM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | HP-UX | 1 | 10-16-2006 04:16 PM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | Shell Programming and Scripting | 0 | 09-19-2006 09:44 PM |
| How to get sysdate -1 | gopskrish | UNIX for Dummies Questions & Answers | 2 | 06-23-2005 06:38 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
Except if you run it on the 1st, then 1-2 = -1. Oops.
A portable solution is to convert the current date to a julian value, subtract 2 and then convert back to a gregorian value. A script to convert to/from julian date is here: http://droflet.net/julian.txt Last edited by PxT; 08-28-2001 at 02:49 PM.. |
|
||||
|
this login does not work with number greater than the days passed in the going month.
plz try this script it will fail . #!/usr/bin/sh echo "Plz enter the number of diff required" read _diff _day=`date +%d` _month=`date +%m` _year=`date +%y` newday=`expr $_day - $_diff` echo "Two days ago was $_month/$newday/$_year " |
|
|||||
|
Yeah, that is the shortcoming that PxT pointed out in my script also. I like his idea better of converting to julian date, subtracting the number you need, then converting back to regular date. Please check out his script - it's much better, and is less likely to contain the simple errors I have included (as features, of course) in mine. ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|