Using the Find Command

Written by Barry Dysert (last updated July 13, 2020)

A great utility that exists at the Windows command line is the Find command. If you want to find a string that may exist in a number of files, Find can be a good friend. Without it, you'd likely import your files into Word and use its searching capabilities to do the deed. Using Find at the command line is much quicker, especially when you want it to work across many files.

The Find command accepts several switches to augment how it works. For a complete list of switches, type the following at a command prompt:

C:\> FIND /?

The simplest format of the Find command is

FIND "string to find" files

Let's say that I have two files named Barry1.tmp and Barry2.tmp. They contain some random text, and I want to find all of the lines in those two files that include the word "document". My Find command would look like this:

C:\> FIND "document" Barry?.tmp

This produces the following output: (See Figure 1.)

Figure 1. A simple FIND command.

By default, Find is case sensitive, so if I had instead tried to find "DOCUMENT" (all caps), I'd come up empty: (See Figure 2.)

Figure 2. By default, FIND is case sensitive.

To make Find case insensitive, specify the "/I" switch so that no matter what case the search string is, it will be found: (See Figure 3.)

Figure 3. Using "/I" to make FIND ignore case.

If you want to know what line numbers each of the found strings occurs on, use the "/N" switch like so: (See Figure 4.)

Figure 4. Using "/N" to display line numbers.

Finally, if you don't care to see the lines themselves but merely want to know how many lines contain the searched-for string, you can use the "/C" switch. This lists each file followed by the number of lines that contain the search string: (See Figure 5.)

Figure 5. Using "/C" to display line counts.

Here we see that each file contains 5 lines with the string "document" in them.

 This tip (13501) applies to Windows 7, 8, and 10.

Author Bio

Barry Dysert

Barry has been a computer professional for over 35 years, working in different positions such as technical team leader, project manager, and software developer. He is currently a software engineer with an emphasis on developing custom applications under Microsoft Windows. When not working with Windows or writing Tips, Barry is an amateur writer. His first non-fiction book is titled "A Chronological Commentary of Revelation." ...

MORE FROM BARRY

Disabling Automatic Updates

If you don't like that Windows automatically downloads and applies updates in the middle of the night, you can gain some ...

Discover More

Understanding Processes in the Task Manager

Your computer is typically running scores of processes behind the scenes of the relatively few windows you may have open. ...

Discover More

Understanding Windows Aero

Windows Aero, first introduced with Windows Vista, provides a nice visual experience when working on your computer. And ...

Discover More
More WindowsTips

Displaying the Command Prompt in Windows 8

Some commands require the use of the command prompt window. How you display that essential window in Windows 8 can be a ...

Discover More

Counting Files and Subfolders Using the Command Prompt

There are times when you might need to know how many files or subfolders are in a folder. Using the command prompt, you ...

Discover More

Displaying All the Files in a Folder using the Command Prompt

Displaying all the files a folder contains is an easy task in Windows. One way you can display the files is using command ...

Discover More
Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is nine minus 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


Newest Tips