I’m having a bit of an issue with grep that I can’t seem to figure out. I’m trying to search for all instances of lower case words enclosed in double quotes (C strings) in a set of source files. Using bash and gnu grep:
grep -e '"[a-z]+"' *.cpp
gives me no matches, while
grep -e '"[a-z]*"' *.cpp
gives me matches like “Abc” which is not just lower case characters. What is the proper regular expression to match only “abc”?
You’re forgetting to escape the meta characters.
For the second part, the reason it is matching multi-case characters is because of your locale. As follows:
To get the “ascii-like” behavior, you need to set your locale to “C”, as specified in the grep man page: