looks like a nightmare
For Unix clones everywhere there's the tried and tested Plan9 Plumber that uses Regular Expression Matching to perform any action you desire
http://swtch.com/plan9port/man/man4/plumber.html
For the example rules see the base set