I have encountered several times the case when I want to search a part of the word, grep fails to find those matches. It works when I search full word.
For example, I need to find all files that contain "mysql_" word. Because I am dealing with legacy code that uses "mysql" instead of "mysqli" to work with a database, and want to see how much of the code uses "mysql".
Now, my command is
grep -rnw './' -e "mysql_"
grep -P -rnw '\bmysql_' .
This still doesn't work.
But if I type:
grep -rnw './' -e "mysql_query"
then of course, grep finds all matches.
What am I doing wrong?