home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10722 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.0 KB  |  30 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!nwnexus!ole!ssc!fyl
  3. From: fyl@ssc.wa.com (Phil Hughes)
  4. Subject: Re: Awk and getting the current date
  5. Organization: SSC, Inc.,  Seattle, WA
  6. Date: Thu, 03 Sep 1992 17:12:01 GMT
  7. Message-ID: <1992Sep03.171201.7724@ssc.wa.com>
  8. X-Newsreader: Tin 1.1 PL3
  9. References: <1992Sep1.214207.1@sc9>
  10. Lines: 18
  11.  
  12. mbrodesky@sc9 writes:
  13. : How can I get the current date in a AWK program
  14.  
  15. This is the most awk-ish way to do it:
  16.  
  17.     awk 'BEGIN  {print dt}' dt="`date`"  file
  18.  
  19. The "program" in this example just consists of the "print dt" statement
  20. performed at begin time.  Following the program, dt="`date`" executes
  21. the date command (because of the backquotes) and then assigns the result
  22. to the awk variable dt.  The double quotes are needed as executing date
  23. expands to multiple words.
  24.  
  25. -- 
  26. Phil Hughes, SSC, Inc. P.O. Box 55549, Seattle, WA 98155  (206)FOR-UNIX
  27. >>> Publishers of pocket references for UNIX, C, VI, Emacs, Ksh, MS-DOS, ... <<<
  28.      uunet!nwnexus!ssc!fyl or fyl@ssc.wa.com            (206)527-3385
  29.  
  30.