CQM-148 Use '-r' or '-E' option depending on the OS type
CQM-148 Code review/shellcheck fixes
CQM-148 sed -r option doesn't work on MacOS X