Switched from sed to perl, should work on OSX