Command: find

  FIND displays lines in one or more text files that contain a string.

Syntax:

  FIND [ /C ] [ /I ] [ /N ] [ /V ] "string" [[drive][path]file1]
  FIND [/?]
    drive     The drive letter, e.g. C:
    path      The directory, e.g. \example\
    file1     The file(s) you wish to search, e.g. test.txt
    Note:     If you do not specify a file, find will take
              input from the console. Type Ctrl-Z to finish.
    "string"  The string of signs you want to find, e.g. "water" or
              "0123". The string must be marked by quotation marks.

Options:

  /C        Only displays a count of the matching lines.
  /I        Ignore case during the comparison ("cAsE").
  /N        Number the displayed lines, starting at 1.
  /V        Inverts the search: displays lines that do NOT
            contain the string.
  /?        Shows the help.

Comments:

  FIND supports NLS (national language support) and DOSLFN
  FIND has the following EXITCODES (ERRORLEVEL):
    0  found
    1  none found
    2  other errors, e.g. syntax errors

Examples:

  find /C "set" c:\fdauto.bat finds results for "set" but not for "SET".
  find /C "SET" c:\fdauto.bat finds NO results for "set" only for "SET".
  find /C /I "sEt" c:\fdauto.bat finds results for "set" and "SET".
  find /C "set" c:\fdauto.bat c:\fdconfig.sys finds results for "set"
                in fdauto.bat and in fdconfig.sys, if there exist some.

  find test.txt
  Hello world
  In this line the characters test.txt are inside.
  In this line the characters test.txt are inside.
  In this line the characters are not inside.
  Each line with test.txt inside repeats this text.
  Each line with test.txt inside repeats this text.
  Means: If you don't specify a search term, the first argument is
  interpreted as a search term and not as a file name. The standard
  input is used as input. Exit with CTRL-C or Z.

  find /n "hello"
  Hi, hello,
  1:Hi, hello,
  how are you?
  Are you fine?
  Hello, please                   (Hello, not hello!)
  give me an answer!
  hello, please please give me    (hello, not Hello!)
  6:hello, please please give me  (6: = line 6)
  an answer
  CTRL-Z or CTRL-C exits the program

See also:

  doslfn
  exitcode/errorlevel
  xgrep

  Copyright © 2004 Robert Platt, updated 2011 and 2022 by W. Spiegl.

  This file is derived from the FreeDOS Spec Command HOWTO.
  See the file H2Cpying for copying conditions.