Search code examples
windowscommanddospromptfindstr

What does the DOS command "findstr" do here?


From my understanding of findstr, it looks for text within files. What, then, is making it search for a pattern in the filename itself?

dir | findstr "test[0-9][0-9][0-9]test"

Does the pipe alter its behavior? Someone explain the inner working of this. I know it works, but I don't understand how it works. Thanks.


Solution

  • The pipe redirects the standard output of dir to the standard input of findstr, this works as findstr will use either the arguments passed to it on the command line, or anything passed to it via stdin.