Find Command
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.
Usage:find
[/options]
"string"
[filename]
/v
Displays all lines NOT containing the specified string.
/c
Displays only the count of lines containing the string.
/n
Displays line numbers with the displayed lines.
/i
Ignores the case of characters when searching.
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?