Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ find(CMD) — OpenDesktop 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought


 find(CMD)                       19 June 1992                       find(CMD)


 Name

    find - search for a specific string of text in a file or files

 Syntax


    find [/v] [/c] [/n] [/i] "string" [[drive:][path] filename[...]]


 Description

    After searching the specified files, find displays any lines of text that
    contain the specified string.

 Parameters


    string Specifies the group of characters you want to search for. You must
           enclose the text for string in quotation marks.

    [drive:][path]filename
           Specifies the location and name of the file in which to search for
           the specified string.


 Switches


    /v     Displays all lines not containing the specified string.

    /c     Displays only a count of the lines that contain the specified
           string.

    /n     Precedes each line with the file's line number.

    /i     Specifies that the search is not to be case-sensitive.


 Notes


    Specifying a string

    Unless you specify the /i switch, find searches for exactly what you
    specify for string.  For example, to the find command, the characters
    ``a'' and ``A'' are different. If you were to use the /i switch, however,
    find would ignore case and search for ``a'' and ``A'' as if they were the
    same character.

    If the string you want to search for contains quotation marks, you must
    use two quotation marks for each quotation mark contained within the
    string.

    Using find as a filter

    If you omit a filename, find acts as a filter, taking input from the
    MS-DOS standard source (usually the keyboard, a pipe, or a redirected
    file) and displaying any lines that contain string.

    Using wildcards with find

    You cannot use wildcards (* and ?) in filenames or extensions that you
    specify with the find command.  To search for a string in a set of files
    you specify with wildcards, you can use the find command in a for com-
    mand.

    Using the /v or /n switch with the /c switch

    If you specify the /c and /v switches in the same command, find displays
    a count of the lines that do not contain the specified string.  If you
    specify the /c and /n switches in the same command, find ignores the /n
    switch.

    Using find in files with carriage returns

    The find command does not recognize carriage returns.  When you use find
    to search for text in a file that includes carriage returns, you must
    limit the search string to text that can be found between carriage
    returns-that is, a string that is not likely to be interrupted by a car-
    riage return. For example, find does not report a match for the string
    ``tax file'' wherever a carriage return occurs between the word ``tax''
    and the word ``file''.

 Examples

    To display all lines from the file PENCIL.AD that contain the string
    ``Pencil Sharpener'', type the following command:

       find "Pencil Sharpener" pencil.ad


    To find a string that contains text within quotation marks, you must
    enclose the entire string in quotation marks and, in addition, use two
    quotation marks for each quotation mark contained within the string, as
    shown in the following example:

       find "The scientists labeled their paper ""for discussion only.""
       It is not a final report." report.doc


    If you want to search for a set of files, you can use the find command
    with the for command.  The following command uses this method to search
    the current directory for files that have the extension .BAT; in each
    file found, the command searches for the string ``PROMPT'':

       for %f in (*.bat) do find "PROMPT" %f


    Suppose you want find to search your hard disk to find and display the
    filenames on drive C that contain the string ``CPU''.  To do this you can
    use the pipe (|) to direct the results of a dir command to find, as shown
    in the following example:

       dir c:\ /s /b  find "CPU"


    Before using a pipe for redirection, you should set the TEMP environment
    variable in your AUTOEXEC.BAT file.

    Since find searches are case-sensitive and since dir produces uppercase
    output, you must either type the string ``CPU'' in uppercase letters or
    use the /i switch with find.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026