I want to search one string e.g. "main" in my project on windows OS recursively. I searched that and find a solution Windows recursive grep command-line
I applied same with two different approach, and result is not as expected.
e.g. my approach
findstr /S "main" *.cpp
but when I choose
findstr /S "int main" *.cpp
I am not getting only my main function. What is the difference between these two approaches? is it wrong to provide strings with space?
This is because findstr
takes a set of strings to search for. To actually match the string int main
you have to use the /C
option:
findstr /s /C:"int main" *.cpp
whereas your variant gives you every line with either int
or main
.
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