home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!usc!sdd.hp.com!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!dslg0849
- From: d-lewart@uiuc.edu (Daniel S. Lewart)
- Subject: Re: Awk question
- References: <BtxLJ3.BzE@nntp-sc.Intel.COM>
- Message-ID: <Bty0BG.14x@news.cso.uiuc.edu>
- Originator: dslg0849@uxa.cso.uiuc.edu
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Reply-To: d-lewart@uiuc.edu (Daniel S. Lewart)
- Organization: University of Illinois at Urbana
- Date: Wed, 2 Sep 1992 08:45:14 GMT
- Lines: 24
-
- brodesky@td2cad.intel.com (Michael Brodesky) writes:
-
- > I would like to get the current year into my awk program. Any
- > clues into doing this?
-
- If you have `gawk' with the `strftime' function, then use this:
- #! /usr/local/bin/gawk -f
- BEGIN {
- print strftime("%Y")
- }
-
- If you have `gawk', `nawk', or `awk' with the getline function, then use this:
- #! /bin/awk -f
- BEGIN {
- "date +19%y" | getline y
- print y
- close("date +19%y")
- }
-
- Else use this:
- awk 'BEGIN { print y }' y=`date +19%y`
-
- Daniel Lewart
- d-lewart@uiuc.edu
-