0

So here's the question. I type in findstr "a" in the command prompt then it just shows a blank screen. If I type in a string with an "a" in it, then cmd will return a duplicate of the string I typed in after hitting enter a few times. I just am curious as what is happening.

Example 
B:\Desktop>findstr "a"
a

a
  • I have also looked around, googled it and what not. I can't seem to find the explaination. One post talks about the terrible documentation of findstr but doesn't cover this. http://stackoverflow.com/questions/8844868/what-are-the-undocumented-features-and-limitations-of-the-windows-findstr-comman –  Jun 25 '15 at 06:13

1 Answers1

0

Findstr finds strings in a file. If you don't specify a filename, data is accepted from the keyboard, so you can type to your heart's content. Whenever you enter a string containing the target, findstr will report that string when you press enter. You may terminate the entry-from-keyboard by entering a control-Z keystroke (press control and z simultaneously. This is a standard end-of-file character from the CP/M days, where filesizes were in blocks of 128 bytes, not in bytes, so a control-Z (usually shown as ^Z) was used to indicate a partially-filled block.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • What usefulness of this behavior could one find for scripting? Or I guess, why would they put this functionality into the command? –  Jun 25 '15 at 06:15
  • In general, batch utilities read from `stdin`, write to `stdout` and produce error messages to `stderr`, where `std*` are standard virtual devices, assigned by default to keyboard, screen and screen. These can be redirected to files or other devices at will, so `type filename` would type the contents of `filename` to the screen for instance. It's possible to code `type filename |findstr "target"` to redirect the output of `type` to the input of `findstr`, so it's not a characteristic of deliberate functionality but illogical assignment of devices on the coder's part. – Magoo Jun 25 '15 at 07:19