condense sed into grep

Using a perl regex, both commands can be merged into one.