KarstenJHilton
IS-IT--Management
I have been looking for 2 days for a solution for this, and now I am hoping someone with master awk skills can guide me in the way of what I am trying to do.
Problem:
I have a file that has dates in it, and I need to only see those that are less than, or equal to the system's date(Current Date). the format of the date in the file is DD Mon YYYY (30 Aug 2012). If I cat test_file, I see this output.
03 Oct 2012
03 Feb 2012
03 Jun 2012
29 Aug 2012
03 Oct 2012
03 Oct 2012
03 Aug 2012
30 Aug 2012
30 Aug 2012
Now if I run cat test_file | awk '{print "date -d\""$1FS$2FS$3"\" +%Y%m%d"}' | bash
I get this this output, which is what I think I am needing to do the <= comparison.
20121003
20120203
20120603
20120829
20121003
20121003
20120803
20120830
20120830
In my simple test script, here is what I have.
#!/bin/ksh
dt=$(date +"%Y%d%m")
fil='cat test_date_file'
$fil|awk '{print "date -d\""$1FS$2FS$3"\" +%Y%m%d"}' | bash
You can see I have the date command pulling the system date in the yyyymmdd to match the awked date.
So, how would I pull the specific dates I am wanting that are <= to current date.
Any help would be appreciated, and thanks in advance.
Thanks,
Karsten
Problem:
I have a file that has dates in it, and I need to only see those that are less than, or equal to the system's date(Current Date). the format of the date in the file is DD Mon YYYY (30 Aug 2012). If I cat test_file, I see this output.
03 Oct 2012
03 Feb 2012
03 Jun 2012
29 Aug 2012
03 Oct 2012
03 Oct 2012
03 Aug 2012
30 Aug 2012
30 Aug 2012
Now if I run cat test_file | awk '{print "date -d\""$1FS$2FS$3"\" +%Y%m%d"}' | bash
I get this this output, which is what I think I am needing to do the <= comparison.
20121003
20120203
20120603
20120829
20121003
20121003
20120803
20120830
20120830
In my simple test script, here is what I have.
#!/bin/ksh
dt=$(date +"%Y%d%m")
fil='cat test_date_file'
$fil|awk '{print "date -d\""$1FS$2FS$3"\" +%Y%m%d"}' | bash
You can see I have the date command pulling the system date in the yyyymmdd to match the awked date.
So, how would I pull the specific dates I am wanting that are <= to current date.
Any help would be appreciated, and thanks in advance.
Thanks,
Karsten