So....how would I use this in a script? I finally got the python version of
futureTasks working, but when I try to save the attached awk script as a file,
and point to that for my final filter, I get interesting errors like:
F:\Dropbox\My Dropbox\TextFiles>t get testing
/cygdrive/f/dropbox/mydrop~1/textfiles/.todo/future: line 4: $'\r': command not
found
/cygdrive/f/dropbox/mydrop~1/textfiles/.todo/future: line 5: BEGIN: command not
found
/cygdrive/f/dropbox/mydrop~1/textfiles/.todo/future: line 7: syntax error near
unexpected token `('
'cygdrive/f/dropbox/mydrop~1/textfiles/.todo/future: line 7: `today =
strftime("s:%Y-%m-%d")
I'm using this through Cygwin on a WinXP machine. Is there something fancy to
put as the first line in the file, like in a bash script? Should it be saved as
a file at all?
Much appreciated...
--- In todotxt@yahoogroups.com, Ed Blackman <ed@...> wrote:
>
> On Tue, May 12, 2009 at 09:32:25PM +0100, Frederik Dohr wrote:
> >Would you mind sharing that awk command?
>
> Not at all. I've attached it.
>
> Ed
>
>
> # This script relies on the fact that a lexical sort of YYYY-MM-DD datestrings
> # produces the same result as a calendar sort, but avoids the tricky calendar
> # math. It will *not* work for other types of datestring.
>
> BEGIN {
> # save today's date in a t:YYYY-MM-DD datestring
> today = strftime("t:%Y-%m-%d")
> }
> {
> # should this line be printed? default yes
> doPrint = 1
>
> # iterate over each "field" (space-delimited words)
> for(i = 1; i <= NF && doPrint; i++) {
> # does this field match a t:YYYY-MM-DD datestring?
> m = match($i, "t:[0-9]{4}-(0?[0-9]|1[0-2])-([0-2]?[0-9]|3[01])");
>
> # if so, and the datestring is lexically after today's datestring, don't
print
> if(m > 0 && $i > today) {
> doPrint = 0
> }
> }
>
> if(doPrint) {
> print $0
> }
> }
>