grep -P is a GNU thing, it is not supported in the BSD versions of grep. How can I make the script work?