Mixing awk with C and sh.

sdougiama at cc.curtin.edu.au sdougiama at cc.curtin.edu.au
Fri May 31 19:09:58 AEST 1991


New Bruce - Another tube... and a question.
 
I have a file of lines, each line has the same number of fields, separated
by tabs.  The second field in each line is a date in the form: 'dd-mmm-yy'

eg.  31-May-91
 
What I want to do is print all the lines with a date that is some x days
before the current date.  I have already written a C program that takes
two dates in a variety of formats and returns the number of days between them.

eg.
# compare_date  21-Apr-91 31/5/91
40
#
 
So what I'd like to do is write some awk program that does:
 
for each line in the file
  extract date
  difference <= compare_date  extractdate  currdate
  if difference < x then
     output the current line
endfor
 
However I can't think of a way to do this, not being very experienced with awk.
Is there someone there who could help me out?
Is there a simpler way?  Is there *any* way?
I'd like a simple awk or sh solution if possible, but any help is appreciated.

[ This will be part of a portable shell-based BBS I'm writing.
  The file in question is a catalog of uploaded files, and I want to list
  all the recent uploads within certain time frames. ]
 
Martin
,-------------------------+---------------------------------------n------.
| "There's nothing quite  | Martin Dougiamas.                ,-\_/ \     |
|  so fun as a good,      | SDOUGIAMA at cc.curtin.edu.au      /  |    \    |
|  solid poke in the eye  | Curtin University               \  |_   /    |
|  with a pencil."  o.x   | Perth, Western Australia. ---->  x-' `_'     |
`===================\_/===+=======================================V======'



More information about the Comp.unix.shell mailing list