Please change "grep -nP" to "egrep -n" - the -P option is not supported in OS X's grep, and egrep works everywhere.