Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching recursively one string on windows OS

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?

like image 379
someone Avatar asked Aug 02 '13 05:08

someone


1 Answers

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.

like image 71
Joey Avatar answered Sep 22 '22 15:09

Joey