Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!munnari.oz.au!uniwa!cc.curtin.edu.au!sdougiama From: sdougiama@cc.curtin.edu.au Newsgroups: comp.unix.shell Subject: Mixing awk with C and sh. Message-ID: <1991May31.170958.8529@cc.curtin.edu.au> Date: 31 May 91 09:09:58 GMT Article-I.D.: cc.1991May31.170958.8529 Organization: Curtin University of Technology Lines: 41 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@cc.curtin.edu.au / | \ | | solid poke in the eye | Curtin University \ |_ / | | with a pencil." o.x | Perth, Western Australia. ----> x-' `_' | `===================\_/===+=======================================V======'