Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between find and findstr in Windows CMD?

find /? prints:

Searches for a text string in a file or files.

and

findstr /? prints:

Searches for strings in files.

What is the difference between these two?

like image 808
Giorgi Tsiklauri Avatar asked Oct 17 '25 00:10

Giorgi Tsiklauri


1 Answers

findstr has way more options than find, for example, /B to look only at the respective beginning of each line. Further, even the matching functionality has a different syntax.


Concerning the question why Microsoft would keep both instead of just extending one with the features of the other I can just speculate:

As a software developer I know that in many cases it is hard to extend an existing command with new features without breaking backwards-compatibility - which is very important when talking about operating systems. So, the easy solution is to introduce a new command and wait for the users to forget about the deprecated one. Which may never happen.

A slightly different explanation can be found for commands like rd and rmdir. While the former is originating from the original MS DOS the latter is part of the UNIX tradition. It makes sense to keep both to make it comfortable for programmers familiar with only one of these. I don't know if there is an explanation in the history of find, though.

like image 196
n0dus Avatar answered Oct 19 '25 12:10

n0dus