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

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!usc!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!dslg0849
  3. From: d-lewart@uiuc.edu (Daniel S. Lewart)
  4. Subject: Re: Awk question
  5. References: <BtxLJ3.BzE@nntp-sc.Intel.COM>
  6. Message-ID: <Bty0BG.14x@news.cso.uiuc.edu>
  7. Originator: dslg0849@uxa.cso.uiuc.edu
  8. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  9. Reply-To: d-lewart@uiuc.edu (Daniel S. Lewart)
  10. Organization: University of Illinois at Urbana
  11. Date: Wed, 2 Sep 1992 08:45:14 GMT
  12. Lines: 24
  13.  
  14. brodesky@td2cad.intel.com (Michael Brodesky) writes:
  15.  
  16. > I would like to get the current year into my awk program. Any
  17. > clues into doing this?
  18.  
  19. If you have `gawk' with the `strftime' function, then use this:
  20.     #! /usr/local/bin/gawk -f
  21.     BEGIN {
  22.         print strftime("%Y")
  23.     }
  24.  
  25. If you have `gawk', `nawk', or `awk' with the getline function, then use this:
  26.     #! /bin/awk -f
  27.     BEGIN {
  28.         "date +19%y" | getline y
  29.         print y
  30.         close("date +19%y")
  31.     }
  32.  
  33. Else use this:
  34.     awk 'BEGIN { print y }' y=`date +19%y`
  35.  
  36. Daniel Lewart
  37. d-lewart@uiuc.edu
  38.