Finds recursively all files not having extension .o in '/path/' that contain 'pattern', and prints matched strings with string number and file name.
grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"