home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!coplex!trebor!root
- From: root@trebor.uucp (Bob Stockler)
- Subject: Re: Date math
- Organization: Bob Stockler
- Distribution: comp.unix.shell
- Date: Sat, 07 Nov 1992 22:01:08 GMT
- Message-ID: <1992Nov07.220108.9287@trebor.uucp>
- References: <1992Nov6.150339.596@cheshire.oxy.edu>
- Keywords: date math shell utility
- Lines: 29
-
- legend@cheshire.oxy.edu (Linda A. Malcor) writes:
-
- >Simple question: Is there a simple utility to tell me what tomorrow is?
- >I want something like "date" which allows me all the formating in the
- >world and a simple +1 day/week/month type of math.
-
- This little Bourne Shell script fragment will print tomorrow's date for
- you in whatever format you give to the "date" command in its 4th line:
-
- GMTDIFF=`expr $TZ : '...\(.*\)...'`
- TOMORROW=`expr $GMTDIFF - 24`
- ifs=$IFS; IFS=$GMTDIFF; set $TZ; IFS=$ifs
- DATE=`TZ=$1$TOMORROW$2 date +%D`
- echo $DATE
-
- This assumes your environmental parameter TZ is in the same format as
- mine: "EST5EDT". (I got the idea for this from Jean-Pierre Radley.)
-
- BTW, have you ever executed (in the Bourne Shell):
-
- ALPHA="A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"
- alpha="a b c d e f g h i j k l m n o p q r s t u v w x y z"
- for a in $ALPHA $alpha
- do echo "$a - `date +%$a`"
- done | more
-
- to see if your "date" command supports more conversions than are
- mentioned in your man pages? Some do (mine did). Try it.
-
-