Sideway
output.to from Sideway
Draft for Information Only

Content

MS DOS Command: FIND.EXE
 Description
 Syntax
 Parameters
 Switches
 Remarks
  Specifying a string
  Using FIND as a filter
  Using wildcards with FIND
  Using the /V or /N switch with the /C switch
  Using FIND in files with carriage returns
  FIND exit codes
 Examples

MS DOS Command: FIND.EXE

Reference from Microsoft MS-DOS cmd help

Description

Searches for a specific string of text in a file or files.

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

Syntax

FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[...]]

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.

Remarks

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 the 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 command.

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 carriage 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".

FIND exit codes

The following list shows each exit code and a brief description of its meaning:

0 The search was completed successfully and at least one match was found.
1 The search was completed successfully, but no matches were found.
2 The search was not completed successfully. In this case, an error occurred during the search, and FIND cannot report whether any matches were found.

You can use the ERRORLEVEL parameter on the If command line in a batch program to process exit codes returned by FIND.

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.


©sideway

ID: 110700187 Last Updated: 7/27/2011 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Travel 18

Reference 79

Computer

Hardware 254

Software

Application 213

Digitization 37

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 431

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2025 Sideway . All rights reserved Disclaimers last modified on 06 September 2019