Fix sed cross-platform compatibility issues

Switch to using awk/grep due to differences in sed flags between BSD and GNU versions of sed for extended regular expressions