Created
May 5, 2012 21:21
-
-
Save xrat/2605649 to your computer and use it in GitHub Desktop.
Shorter Future Tasks.awk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
# | |
# Original script by Ed Blackman, posted May 12, 2009, at | |
# http://tech.groups.yahoo.com/group/todotxt/message/2299 | |
# | |
# Ruthlessly reduced by Andreas Schamanek in May, 2012. | |
# | |
# This script relies on the fact that a lexical sort of YYYY-MM-DD | |
# date strings produces the same result as a calendar sort, but avoids | |
# the tricky calendar math. It will *not* work for other types of | |
# date string. | |
BEGIN { | |
# today's date in a t:YYYY-MM-DD datestring | |
TODAY = strftime("t:%Y-%m-%d") | |
# the date format needs to reflect the regular expression | |
DATEREGEX="t:[0-9][0-9][0-9][0-9]-(0?[0-9]|1[0-2])-([0-2]?[0-9]|3[01])" | |
} | |
{ | |
# if t:YYYY-MM-DD is found, and the date (substr) is in the future | |
# skip the line (next) else print it | |
if (match($0, DATEREGEX) && (substr($0, RSTART, RLENGTH) > TODAY)) next | |
else print | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment