findstr

from Wikipedia, the free encyclopedia

findstr is a command line command that is only available in Windows NT -based operating systems. In contrast to the older Find , which already existed under MS-DOS , findstr supports regular expressions and thus offers a range of functions similar to the Unix grep command .

findstr can search for one or more files for the specified regular expression (s) and then outputs the complete line in which the specified regular expression occurs for each search result.

The command is insufficiently documented by Microsoft; many functions of this command are undocumented.

Criticisms

  • The specification of areas is interpreted differently than in all other programs with regular expressions: findstr does not use the ASCII table here, but the Unicode Collation Algorithm , which actually has a completely different purpose. As a result, a search for the range will [A-Z]not only find the uppercase letters A to Z, but also various combinations with diacritics and also all lowercase letters with the exception of the small a, because the small a is placed before the capital A. Likewise, a search for the area [0–9]not only finds the digits 0 to 9, but also the characters ½, ¼ and the superscript ² (but not the superscript ³). As a result, specifying ranges is generally not recommended as the results are completely unpredictable.
  • Problems arise with some parameters if a file has different file extensions in the long format and in the 8.3 format (which happens, for example, if the file extension is longer than three characters). When using wildcards it can sometimes happen that no files are found at all.
  • If a file is findstr < datei.txtread in via the standard input ( ) and this file has no line feed as the last character, the program hangs as soon as the end of the file is reached.
  • In operating systems up to Windows XP , the search command cannot be longer than 127 characters. As of Windows Vista , the limit for literal terms is 511 characters, but only 254 characters when using regular expressions.
  • The search for several literal terms may fail for inexplicable reasons if they are of different lengths.
  • A search can only contain up to 15 character classes. If more are specified, findstr crashes completely.
  • Cannot search for certain characters. The zero character 0x00must not appear in the search term; in a file, it is handled in a similar way to the C programming language; everything that comes after this sign counts as a new line. For this reason findstr does not support searching in text files encoded in UTF-16 or UTF-32 . If the character is 0xFFpart of a regular expression, the program hangs; this is particularly problematic due to the collation algorithm used by findstr, because this character is sorted between the space and the tabulator character and therefore z. B. the specification of a range that contains these two characters is automatically 0xFFincluded.

Individual evidence

  1. Why does findstr not handle case properly (in some circumstances)? - Stack overflow
  2. a b c d e f What are the undocumented features and limitations of the Windows FINDSTR command? - Stack overflow

Web links