The find command searches for a specific string of text in a file or files. It's a simple, fast way to locate lines that contain a particular word or phrase.
Try the command
Search for errors in a log!
Build the command
find
/nDisplays line numbers with the displayed lines.
Terminal
C:\Users\User>find /v "Error" log.txt
Common Options
- /I: Case-insensitive search. Matches "Error", "error", and "ERROR".
- /N: Shows line numbers, which is very helpful for locating the exact position of the text.
- /C: Just counts matching lines. Useful if you want to know how many errors occurred, not see them all.
- /V: Inverts the search. Shows everything except lines containing the string.
Real-World Examples
1. Finding lines with "Error"
Locate specific events in a log file.
Command Prompt
C:\Users\User>find "Error" app.log
2. Counting the number of users
If you have a list of users, verify how many there are.
Command Prompt
C:\Users\User>find /c "User:" users.txt
3. Filtering command output
You can pipe output into find. For example, checking if a specific task is running.
Command Prompt
C:\Users\User>tasklist | find "notepad"
Knowledge Check
1 / 3Matches are case-sensitive by default. Which flag ignores case?
References
These documentation links provide authoritative details for the commands used in this article.