FIND – Windows CMD Command

Search for a text string in a file & display all the lines where it is found.

If a [pathname] is not specified, FIND will prompt for text input or will accept text piped from another command.
(use CTRL-Z to end manual text input)

If searching for text that contains double quote characters “, they must be escaped by doubling to “”
This is in addition to enclosing the entire string in quotation marks: “The “”main”” event”

The FIND command will output a string of 10 dashes ———- followed by the filename being searched, followed by any matching lines of text in the file.

Errorlevel

FIND will return an ErrorLevel as follows:

0 String found in at least one of the files.
1 String not found
2 If any files in the list do not exist or if no files match a wildcard mask. An invalid switch is given.

Limitations

Find does not support wildcards, use FINDSTR instead.

Although FIND can be used to scan large files, it will not detect any string that is positioned more than 1070 characters along a single line (with no carriage return) This makes it of limited use in searching binary or XML file types.

An empty string “” will normally match nothing, with the/v flag reversing the test, to match everything, but this will fail for any lines longer than 4091 characters long.

You may also like...

1 Response

  1. froleprotrem says:

    I’ve been absent for some time, but now I remember why I used to love this blog. Thank you, I will try and check back more frequently. How frequently you update your site?

Leave a Reply

Your email address will not be published.