Why are there both FIND and FINDSTR programs, with unrelated feature sets?


Jonathan wonders why we have both find and findstr, and furthermore, why the two programs have unrelated features. The find program supports UTF-16, which findstr doesn't; on the other hand, the findstr program supports regular expressions, which find does not.

The reason why their feature sets are unrelated is that the two programs are unrelated.

The find program came first. As I noted in the article, the find program dates back to 1982. When it was ported to Windows NT, Unicode support was added. But nobody bothered to add any features to it. It was intended to be a straight port of the old MS-DOS program.

Meanwhile, one of my colleagues over on the MS-DOS team missed having a grep program, so he wrote his own. Developers often write these little tools to make their lives easier. This was purely a side project, not an official part of any version of MS-DOS or Windows. When he moved to the Windows 95 team, he brought his little box of tools with him, and he ported some of them to Win32 in his spare time because, well, that's what programmers do. (This was back in the days when programmers loved to program anything in their spare time.)

And that's where things stood for a long time. The official find program just searched for fixed strings, but could do so in Unicode. Meanwhile, my colleague's little side project supported regular expressions but not Unicode.

And then one day, the Windows 2000 Resource Kit team said, "Hey, that's a pretty cool program you've got there. Mind if we include it in the Resource Kit?"

"Sure, why not," my colleague replied. "It's useful to me, maybe it'll be useful to somebody else."

So in it went, under the name qgrep.

Next, the Windows Resource Kit folks said, "You know, it's kind of annoying that you have to go install the Resource Kit just to get these useful tools. Wouldn't it be great if we put the most useful ones in the core Windows product?" I don't know what sort of cajoling was necessary, but they convinced the Windows team to add a handful of Resource Kit programs to Windows. Along the way, qgrep somehow changed its name to findstr. (Other Resource Kit programs kept their names, like where and diskraid.)

So there you have it. You can think of the find and findstr programs as examples of parallel evolution.

Comments (35)
  1. Adam V says:

    What idiot logs in and rates this article 1 star within the first 15 minutes?

  2. Grzechooo says:

    TIL there's an app named 'where'.

  3. John says:

    @Adam V:  xpclient.  I actually tend to agree with most of his views, but the rating thing is just childish and petty.

  4. Adam Rosenfield says:

    @John: While I'm aware of xpclient's tendencies, are you just speculating there, or is there some way to find out who's rated a given article if you're logged in?

  5. SimonRev says:

    Unfortunately, I suppose we cannot know for sure that he is the one who gave it 1 star — perhaps 10 people give it one star and he gives it 5.  However we can see that he regularly rates the blog posts right after they are created.

  6. John Doe says:

    @SimonRev, xpclient's rating history strongly correlates him with the 1 star rating that appear by about 10 minutes after each new post. When you see it happen for yourself, it's hard not to notice. It's a very, very strong hint, and one that I think xpclient is not really ashamed of being suspect.

    Even though I'm a John Doe, I find it stupid, and I can't rate. I guess Raymond is kind of immune to trolls, as you can witness at Stack Overflow.

  7. Mason Wheeler says:

    "(This was back in the days when programmers loved to program anything in their spare time.)"

    Huh?  I thought we still did. Most of the programmers I know still do, at least…

  8. jon says:

    And of course neither have been updated since or ever will be as Microsoft simply don't have the resources for that.

  9. Cesar says:

    As an aside, it is an annoyance these commands which have the same name on Unix and Win32 but do different things. It causes potential confusion when using ported versions of the Unix utilities on Windows as part of the build system for portable software.

  10. Ben Coates says:

    If it needs Unix utilities to build, it isn't portable software, it's Unix software.

  11. Myria says:

    Windows really needs an xargs equivalent.  for /f %d in (...) is close but not quite the same.

    I'm with Cesar: I work in a multi-platform environment, and the existence of incompatible utilities of the same name is a problem.  find is the worst offender, being completely unrelated.

  12. JJJ says:

    @Ben Coates:  Your statement is true, but Cesar meant to say POSIX, not Unix.

  13. Joshua says:

    @Cesar: What I do is put a utilities directory with the ported UNIX tools first in the PATH. And yeah, find is the worst offender.

  14. Ross Presser says:

    So if the colleague was writing a grep replacement, why did he use such different commandline parameters from what grep was using??

  15. Evan says:

    @JM: "I've always hated "find", though. It can do anything, but I can never remember the syntax."

    POSIX 'find' is an abomination upon computing. :-)

    In my spare time I'm very slowly trying to build up a set of replacement utilities for the normal POSIX stuff, and inspired a little by PowerShell (though I'm not really looking at what it does specifically, I'm using the idea of piping pseudo-objects around and I have something that displays tables like what you get in PS). I do not see a place for a 'find' equivalent.

  16. keithmo says:

    @Raymond: Are you sure findstr was originally shipped as part of the Win2K Resource Kit? I seem to remember it being shipped with the NT 3.1 retail product. I can't find anything online to confirm this, but I *did* find a mention of the NT 3.5 findstr: support.microsoft.com/…/135606 If true, this means findstr definitely predates Windows 95 and the Win2K RK.

  17. cheong00 says:

    I can't see xpclient's profile by the link, and I found his old posts got removed. Has the banhammer fallen on him?

  18. Drak says:

    @Mason Wheeler: I still do too, because it's fun. I know quite a few programmers who leave work behind when they go home, and come back in the morning to pick it up again though. Maybe Raymond meant that in the early days ALL programmers were like us.

  19. Johannes says:

    Ah, yes, findstr and its plethora of problems and fun :D. One of the top answerers for batch files on Stack Overflow took the time of piecing together all sorts of undocumented things, limitations and shortcomings of findstr: stackoverflow.com/…/73070

    And indeed, PowerShell is probably the reason why there is little need of building better batch file tools. Although I rarely found the need of using Select-String. (Get-Content foo) -match '…' works just as well and I don't have to remember the arguments to Select-String ;-)

  20. JM says:

    Both FIND and FINDSTR have fallen by the wayside for me in favor of PowerShell's Select-String, mostly because PowerShell has advanced wildcard matching for files built-in ("c:here**.log") which obviates the need for weird "for /f" incantations.

    grep is of course still a perennial favorite on Unix. I've always hated "find", though. It can do anything, but I can never remember the syntax.

  21. ender says:

    @keithmo: you're right, findstr is in NT 3.1 already (I've got it installed in VMWare)

  22. Matt says:

    @cheong00 "I can't see xpclient's profile by the link, and I found his old posts got removed. Has the banhammer fallen on him?"

    Clearly so. His account was live when this post happened, and does not exist now. I can only conclude that he either left MSDN or was evicted.

    What an interesting correlation his account vanishing within hours of this post appearing.

  23. John says:

    Nobody's going to ban someone for down-voting blog entries; that's just stupid.  He must have deleted his account out of embarrassment or something.  Too bad; I miss him already.

  24. SimonRev says:

    My guess is he renamed his account.  10 minutes after today's post, Raymond's blog has a 1 star rating.

  25. Brian_EE says:

    @Matt: "What an interesting correlation his account vanishing within hours of this post appearing"

    Ahh, but correlation does not imply causation.

  26. Matt says:

    @Brian_EE: Hence why I studiously avoided making conclusions, or assuming causality.

  27. Brian_EE says:

    @SimonRev: Perhaps he finally upgraded to Vista. Did anyone check is there is a user named "vistaclient"?

  28. xpclient is now msftgaurav: social.msdn.microsoft.com/…/activity

    I just searched the forums for windows 8 feature removed and clicked the first result.

  29. SimonRev says:

    Lol, j3anders, I was just about to post that.  He just posted on today's blog post and has xpclient's history.

  30. Gabe says:

    I'm rather confused. While the QGREP program is part of the reskit, and FINDSTR does describe itself as QGREP in its manifest, FINDSTR shipped with NT 3.x (I remember using it on NT 3.51).

    So does anybody know the real story?

  31. Smitty says:

    Of course, nobody wonders why find was written (for Windows) in the first place, since grep dates to 1973, almost 10 years earlier, and is vastly superior.  And, yes, the source was available.

    [FIND was written for Windows in order to be compatible with MS-DOS. -Raymond]
  32. I think Smitty was asking why FIND was written for MS-DOS, since grep predates MS-DOS.

    The question could perhaps be generalized as, why didn't MS-DOS imitate UNIX?

    [Because MS-DOS was busy imitating CP/M. -Raymond]
  33. 640k says:

    Those who don't understand Unix are condemned to reinvent it, poorly.

  34. I don't remember when FINDSTR became an official part of Windows, but my recollection was that at some point after Windows 2000, a decision was made not to ship RK tools anymore.  Tools either had to find sponsorship and support in Windows proper, or die.  I knew this because they contacted me about the Clear Screen Saver, which I had contributed to the Win2K RK.  It died.

Comments are closed.

Skip to main content