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

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!cs.utexas.edu!torn!cunews!nrcnet0!bnrgate!bcars267!bcarh803!christo
  3. From: christo@bcarh803.BNR.CA (Mark Christopher)
  4. Subject: Re: Awk and getting the current date
  5. Message-ID: <1992Sep3.222004.12240@bnr.ca>
  6. Sender: news@bnr.ca (usenet)
  7. Nntp-Posting-Host: bcarh803
  8. Reply-To: christo@bnr.ca
  9. Organization: Bell-Northern Research Ltd.
  10. References: <1992Sep1.214207.1@sc9> <1992Sep3.135708.28491@rtf.bt.co.uk>
  11. Date: Thu, 3 Sep 1992 22:20:04 GMT
  12. Lines: 21
  13.  
  14. In article <1992Sep3.135708.28491@rtf.bt.co.uk>, duplain@rtf.bt.co.uk
  15. (Andy Duplain) writes:
  16. |>In article <1992Sep1.214207.1@sc9> mbrodesky@sc9 writes:
  17. |>>How can I get the current date in a AWK program
  18. ...
  19. |>        #!/bin/sh
  20. |>        awk -e 'BEGIN { 
  21. |>            date="'`date`'"
  22. |>        }
  23. ...
  24.  
  25. Or in nawk:
  26.  
  27.     nawk 'BEGIN { "date" | getline; date=$0}
  28.         {
  29.           print date,$0
  30.         }'
  31.  
  32. Not tough.  Learn to read the manual.
  33. -- 
  34. Mark Christopher        Bell-Northern Research          christo@bnr.ca
  35.