You can specify multiple files to search in the find command by putting the path to each file in quotes separated by a space. Now that you can search one file for a text string, let’s search multiple files for the same text string. Search Multiple Documents for the Same Text String Now, the phrase was found and the entire line containing the phrase prints to the screen below the path to the file being searched. find /i "groovypost is the best tech site" "C:\Users\Lori\Documents\FindCommandExamples\example1.txt" Add the “ /i” (lowercase or uppercase letter “i”) switch right after the find command (before the phrase) to ignore the case when looking for the text phrase. That’s because the case in “groovypost” did not match what was in the file, which is “groovyPost”. Notice that the phrase was not found in the above example (nothing is listed below the path to the file), even though it is in the file. The quotes are not really needed in this case, but it doesn’t hurt to have them. NOTE: If there are spaces in any part of the path or file name, you must put quotes around the entire path, like we did in the above command. find "groovypost is the best tech site" "C:\Users\Lori\Documents\FindCommandExamples\example1.txt" The following command searches the example1.txt file for the phrase “groovypost is the best tech site”. Search a Single Document for a Text Stringįirst, we’ll show you how to search one document for all occurrences of a text string. The brackets indicate that the switch or parameter is optional. The switches can be in any order as long as they’re before the “string” parameter. The following is the general syntax for the find command. Syntax for the find CommandĪ command’s syntax is a specific way to organize the command and its switches and parameters. The filename parameter can be anything from a drive letter to a single file or multiple files. The switches can be lowercase or uppercase.įor the “string” parameter, you must surround the string with double quotes, otherwise the find command will not work and will return an error. You can get help to see all the available switches for the find command by typing the following line at the prompt and pressing Enter. Most commands have optional switches that modify the default operation of the command. Switches and Parameters for the find Command We don’t recommend disabling UAC entirely. NOTE: You may not see this dialog box, depending on your User Account Control settings. If the User Account Control dialog box displays, click Yes to continue. Then, right-click on the Command Prompt item under Best match and select Run as administrator from the popup menu. Using the find command as administrator is safe as it doesn’t change or delete any files.Įnter cmd.exe in the Search box on the Taskbar. Just be careful what commands you run as administrator on the command line. However, it does help you avoid annoying confirmation dialog boxes. Opening the Command Prompt window as administrator is not necessary. Open the Command Prompt Window with Administrative Privileges Today we’ll cover how to use the find command and we’ll provide some examples. NOTE: The find command is not suitable for large files or large numbers of files. The find command searches for text strings in files and returns the lines of text from the files in which the text string was found. There’s a faster way to search the contents of files on your hard drive using the command line.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |