I am trying to use grep to find the string "crk" in a file. I know the string exists in a c source file in the form
kop.crk_op = CRK_MOD_EXP;
However, when I search using
grep -rnw --include '*.c' '.' -e "crk"
I get an empty result. The line
grep -rnw --include '*.c' '.' -e "crk_op"
works just fine, but that really isn't helpful to me. I assume the '_' character is somehow messing up my search. How can I modify my approach to match all strings of which "crk" is a substring, even when the '_' character is present, or any other character for that matter?
Edit: It seems I got a bit trigger happy on this post. The command
grep -rnw --include '*.c' '.' -e "[^ ]*crk[^ ]*"
seems to work. Alternatively, can someone explain why the extra wildcards are needed?