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