If you use grep like
grep -rnw '/your/path/to/search/' -e 'n getFoo'
grep wouldn't find a file that contains "function getFoo()".
If you only search for 'getFoo' or else 'function getFoo', grep will find the file that contains the function.
So what's the best way to find a file containing part(s) of a string?
Thanks in advance!
You should remove the -w
option which tells grep to only match whole words.
grep -rn '/your/path/to/search/' -e 'n getFoo'
will also search in between word boundaries.
The -w
flag causes whole word matches so it clearly what you don't need.
So what's the best way to find a file containing part(s) of a string?
shopt -s globstar
grep -li 'string to search for' /path/to/search/**
shopt -u globstar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With