workaround limitations of BSD shells and sed