Index | Syntax | Notes FIND | SORT | MORE | Batch



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.
Excluding the FIND syntax FIND " FIND don't found ""FIND""" < FIND.find | FIND /V ""Find"" The above DOS syntax would search any file named "find.find" and the first FIND command would search this file for the following: FIND don't found "FIND" This is commonly used, nothing special and it's descriped above. But it's sometimes possible (with use of two percent marks (%)), to get rid of the pipe ((|) along with the second FIND command). Example: :: Find any Space character located before an asterisk, --- *-- @FIND " % %*" < %0 :: Find any Space character located after... --* --- @FIND "*% % " < %0 The FIND syntax itself, would be excluded from the output of %0.
-Top- | Syntax | Notes FIND | SORT | MORE | Batch


Updated April 3, 2001

Search for
Get a Free Search Engine for Your Web Site



Or  And   Exact