home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / question / 13108 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.4 KB  |  42 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!coplex!trebor!root
  3. From: root@trebor.uucp (Bob Stockler)
  4. Subject: Re: Date math
  5. Organization: Bob Stockler
  6. Distribution: comp.unix.shell
  7. Date: Sat, 07 Nov 1992 22:01:08 GMT
  8. Message-ID: <1992Nov07.220108.9287@trebor.uucp>
  9. References: <1992Nov6.150339.596@cheshire.oxy.edu>
  10. Keywords: date math shell utility
  11. Lines: 29
  12.  
  13. legend@cheshire.oxy.edu (Linda A. Malcor) writes:
  14.  
  15. >Simple question: Is there a simple utility to tell me what tomorrow is?
  16. >I want something like "date" which allows me all the formating in the
  17. >world and a simple +1 day/week/month type of math.
  18.  
  19. This little Bourne Shell script fragment will print tomorrow's date for
  20. you in whatever format you give to the "date" command in its 4th line:
  21.  
  22.   GMTDIFF=`expr $TZ : '...\(.*\)...'`
  23.   TOMORROW=`expr $GMTDIFF - 24`
  24.   ifs=$IFS; IFS=$GMTDIFF; set $TZ; IFS=$ifs
  25.   DATE=`TZ=$1$TOMORROW$2 date +%D`
  26.   echo $DATE
  27.  
  28. This assumes your environmental parameter TZ is in the same format as
  29. mine: "EST5EDT".  (I got the idea for this from Jean-Pierre Radley.)
  30.  
  31. BTW, have you ever executed (in the Bourne Shell):
  32.  
  33.   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"
  34.   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"
  35.   for a in $ALPHA $alpha
  36.   do echo "$a - `date +%$a`"
  37.   done | more
  38.  
  39. to see if your "date" command supports more conversions than are
  40. mentioned in your man pages?  Some do (mine did).  Try it.
  41.  
  42.