home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / unix / question / 14793 < prev    next >
Encoding:
Text File  |  1992-12-20  |  1.7 KB  |  45 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!att!princeton!sheps!bvaughan
  3. From: bvaughan@sheps.Princeton.EDU (Barbara Vaughan)
  4. Subject: Re: Performing simple math on a numeric file from csh
  5. Message-ID: <1992Dec18.041438.17513@Princeton.EDU>
  6. Originator: news@nimaster
  7. Sender: news@Princeton.EDU (USENET News System)
  8. Nntp-Posting-Host: sheps.princeton.edu
  9. Organization: Princeton University
  10. References: <1992Dec17.093546.9935@netcom.com> <1992Dec17.202131.5029@netcom.com>
  11. Date: Fri, 18 Dec 1992 04:14:38 GMT
  12. Lines: 31
  13.  
  14. In article <1992Dec17.202131.5029@netcom.com> dman@netcom.com (Dallman Ross) writes:
  15. >If it well help to generate some help, this could be done under another
  16. >shell than csh, I supposed, since it's going in a script.  Hope someone
  17. >out there will take pity on me!
  18. >
  19. This is your third whining plea; it doesn't include the problem, which I
  20. vaguely remember.  What do you want us to do?  Write your program for you?
  21.  
  22. 1) This can easily be done with awk
  23.  
  24. 2) awk can be learned in no time using just the man pages.  I know, that's
  25. how I learned it. I never heard of awk six months ago.
  26.  
  27. 3) hint 1. Define your field separator (FS) to be either space or colon. 
  28. This will get your hours, minutes and seconds in separate fields. Do this
  29. in the BEGIN{  } section
  30.  
  31. 4) hint 2. Do a pattern match to match login:
  32. /login/{hoursin = $whatever_field_number_hours_ended_up_in; minutesin =, etc.}
  33. Do the same for logout.
  34.  
  35. 5) In section END{   }, do your arithmetic and print out the result.  If
  36. you have more than one login/logout pair, the hoursin, minutesin, etc.
  37. will retain the value of the last records you read, which is what you said
  38. you wanted.
  39.  
  40. 6) Spend the time you spend begging on the net reading your manual.
  41.  
  42. Barbara Vaughan
  43.  
  44.  
  45.