Friday, May 05, 2006

Getting Things Done bash scripts

WandD gets organised!

For the last year we have been managing our todo lists (fairly succesfully) with an old fashioned pen and paper. However when you run your own business unless you are super organised there is always a niggle in the back of your mind that you have forgotten something. In an attempt to get rid of this niggle we had a look at the Getting Things Done philosophy championed by Merlin Mann of 43 folders.

Even despite being ultra organised and super efficient, I don't have the time, or really the knowledge to explain the Getting Things Done philosophy. The bit that makes sense to me, is that as long as you have a process to put things on to your todo list, nothing will fall through the cracks, and we can stop worrying.

This is where the following lifehacker post came in useful. We haven't followed their exact style / syntaxt, but we are now the proud owners of a .txt todo list and some bash scripts to add items, and to mark things as done.

In true open source style our major (albeit not particularly complicated) "improvement" to the bash scripts is to allow you to sort the output of the grep statement in the same command that outputs the line numbers.

Sorting output from grep -n with sort

Since the aim is getting things done, we wanted an easier way of marking things as complete. The examples in the script used simple grep statements to read the todo list. However in order to mark things as complete you need a line number. You can get this by adding the -n flag to grep, however this doesn't allow you to pipe it to sort, which is required for the priorities. At this point I have to admit I am very much a novice at bash so there may be a better way of doing this, but our solution is to use sed to add a space after the line number, which then allows you to pipe this to sort -k2. Sort -k2 sorts on the 2nd item (space delimited) so by adding the space with the sed statement, we get a list of tasks, sorted by priority with the line numbers to allow us to quickly run a script to mark tasks as complete.

grep -n p:projectname todo.txt | sort
cat todo.txt | sed -e 's/^/ /'| grep -n p:projectname | sort -k2

If you have any better ways, or any other nifty tricks (which is probably a bit grand a name for what we have just done!) we would obviously welcome your comments.

Trackback Link: [Getting Things Done bash scripts]


Blogger Graeme Coates said...

Ahhh, D - another contender for the Useless Use of Cat (UUoC) award!

Instead of cat-ing the file into sed using a pipe, use:

sed -e "s/foo/bar/g" filetoprocess

OK it's not much quicker here, but it'll save you time with BIG files as there's only one file access.

Just like:

grep regexp file(s)

(especially useful if you are grepping a directory (use -R for recursion)).


18 May, 2006 12:05  
Blogger Zhu1 木匠 said...

Here is another option,
-t, --to set the field-separator

$ grep -n mail todo.txt | sort -k2 -t:


19 October, 2006 23:32  

Post a Comment

<< Home