How to force `findstr` to ignore `Cannot open` returns
You can make use of 2>nul
:
FINDSTR /SPIN /C:"string" * 2>nul
This will pipe the standard-error stream to null (read more), thus only matches are displayed.
Related videos on Youtube
Foad S. Farimani
Updated on June 04, 2022Comments
-
Foad S. Farimani almost 2 years
I'm trying to use
findstr
to search inside a folder looking for some string:findstr /spin /c:"string" *
however it returns back with a lot of
Cannot open
errors which make it difficult for me to find the exact matches found.When using
Cmder
command:grep -r "string" .
I got
Permission denied
error for the same folders. If I use the command:grep -rs "string" .
it gives me the results nice and clean. Is there a similar flag for
findstr
or a combination ofcmd
commands to do the same?there are already some posts for
findstr
Cannot open
error, explaining what is wrong and how to solve it, but I don't care why it is happening. I just want the command to ignore theCannot open
lines and prints out just the lines with exact matches.