2

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?

Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66

1 Answers1

1

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.

n0dus
  • 121
  • 7
  • So, that means `find` can be deprecated.. as it's effectively useless.. (or to be specific - doesn't bring any value)? – Giorgi Tsiklauri Feb 13 '23 at 07:47
  • 1
    `find` has this nice `/c` switch, that `findstr` has not. Compare `find /?` with `findstr /?` to find the differences. – Stephan Feb 13 '23 at 07:53
  • 1
    @Stephan: this makes the whole question very interesting: if there are more features to `findstr` than to `find` and `find` still has features, not covered by `findstr`, then why did Microsoft not simply extend the features of the `find` command instead of introducing a new command? – Dominique Feb 13 '23 at 08:07
  • 1
    @Dominique this is exactly what I'm saying here.. as currently, it really seems duplication, which confuses and baffles user/client. – Giorgi Tsiklauri Feb 13 '23 at 09:02
  • 2
    `find`: very easy to use, kept unchanged for backward compatibility reasons. `findstr` more "modern" version, serving different purposes (REGEX (well, sort of...), more specific selection methods). Speaking of duplication - see `mkdir /?` and `md /?`, which do literally the same (same for `rmdir` and `rd`). Why? Ask Microsoft... – Stephan Feb 13 '23 at 10:02