It’ll search for the word GNU in the text file. Take a look at the following grep command. The fundamental way of using grep is to search for a basic string.
#COMMAND PROMPT FIND WORD IN FILE LICENSE#
In this example, download the GNU General Public License v3.0 text file. C:\>find /N "windows" C:\boot. For demonstration purposes, grab a sample text file. Still, you have to run the command prompt as administrator and continue with the steps below: Step 1: Go to the search menu again and launch the command prompt CMD as administrator. Windows will list all the files with that name giving the path to it. The command prompt on Windows is capable of recovering files after reformatting a hard drive.
to go to the root directory or otherwise type cdIn the next command, I have added /I and it shows the matching line ignoring the case differences. First, go to the drive you want to search. In the below example, we don’t find any matching lines when we search for ‘windows’.
By default, grep prints the matching lines. man grep grep -A 5 DESCRIPTION DESCRIPTION grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. Multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=optin /fastdetectĬ:\> To print line numbers along with the lines find /N "string" filenameĬ:\> To ignore case in searching for the string, we can add /I switch. An unix command to find a word in files is.