type, more, find and findstr: read and search text files
Text files, logs and CSV files can be read and searched without opening an editor. type prints a file. more shows it a screen at a time. find and findstr pick out the lines that contain a word.
type: print a file
C:\Users\asha\demo>type notes.txt
Buy milk
Call the plumber
Pay the electricity bill
C:\Users\asha\demo>type marks.csv
name,marks
Asha,78
Ravi,45
Meena,92
Kabir,33
Tara,67type is for text. Used on a picture or a program, it prints nonsense and may beep.
more: one screen at a time
For a long file, more pauses after each screenful. Press Space for the next screen, Enter for the next line and Q to stop.
more log.txtIt also works on the output of another command, joined with a pipe, the | sign: dir /s | more.
find: lines that contain some text
find needs the text in double quotation marks, then the file name.
C:\Users\asha\demo>find "ERROR" log.txt
---------- LOG.TXT
09:05 ERROR Printer not found
09:07 ERROR Printer not foundIts switches:
| Switch | Effect |
|---|---|
/i | ignore capital and small letters |
/v | show the lines that do not contain the text |
/c | count the matching lines instead of showing them |
/n | show line numbers |
C:\Users\asha\demo>find /c "ERROR" log.txt
---------- LOG.TXT: 2
C:\Users\asha\demo>find /n /i "printer" log.txt
---------- LOG.TXT
[3]09:05 ERROR Printer not found
[5]09:07 ERROR Printer not found
C:\Users\asha\demo>find /v "INFO" log.txt
---------- LOG.TXT
09:05 ERROR Printer not found
09:07 ERROR Printer not found
09:10 WARN Low disk spaceCounting lines in a file is a common trick: find /c /v "" counts the lines that do not contain nothing, which is all of them.
C:\Users\asha\demo>find /c /v "" marks.csv
---------- MARKS.CSV: 6findstr: a stronger search
findstr does everything find does and more. It needs no quotation marks for a single word, searches several files at once, and understands patterns.
C:\Users\asha\demo>findstr ERROR log.txt
09:05 ERROR Printer not found
09:07 ERROR Printer not found
C:\Users\asha\demo>findstr /n /i "warn error" log.txt
3:09:05 ERROR Printer not found
5:09:07 ERROR Printer not found
6:09:10 WARN Low disk spaceNote the second command. With several words in the quotation marks, findstr finds lines containing any of them. To search for the exact phrase, add /c:.
C:\Users\asha\demo>findstr /c:"Low disk" log.txt
09:10 WARN Low disk spaceSearching many files
Give a wildcard, and each matching line is shown with its file name.
C:\Users\asha\demo>findstr /i "report" *.txt
log.txt:09:02 INFO Opened report.txt
log.txt:09:15 INFO Saved report.txt
report.txt:Sales report for October/s searches the files in subfolders too, and /m lists only the names of files that contain a match.
C:\Users\asha\demo>findstr /s /m /i "report" *.txt
log.txt
old\draft.txt
report.txtUseful findstr switches
| Switch | Effect |
|---|---|
/i | ignore case |
/n | show line numbers |
/s | search subfolders |
/m | print only the names of matching files |
/v | show lines that do not match |
/c:"text" | search for the exact phrase |
/b | match only at the beginning of a line |
/e | match only at the end of a line |
/r | treat the text as a pattern (regular expression) |
Patterns
With /r, a few symbols have special meaning: . is any character, * repeats the previous character, ^ is the start of a line, $ the end, and [0-9] any digit.
C:\Users\asha\demo>findstr /r "^09:0[5-7]" log.txt
09:05 ERROR Printer not found
09:06 INFO Retrying
09:07 ERROR Printer not foundThat shows the lines whose time is between 09:05 and 09:07.
Searching the output of a command
A pipe sends one command's output into another. Searching a long listing is the usual use.
C:\Users\asha\demo>dir /b | findstr /i ".txt"
log.txt
notes.txt
report.txtThe same idea filters the output of any command: tasklist | findstr /i chrome or ipconfig | findstr IPv4.
Saving the result
Send the matches into a new file with >.
C:\Users\asha\demo>findstr ERROR log.txt > errors.txt
C:\Users\asha\demo>type errors.txt
09:05 ERROR Printer not found
09:07 ERROR Printer not foundsort
sort puts the lines of a file in alphabetical order, and /r reverses it.
C:\Users\asha\demo>sort marks.csv
Asha,78
Kabir,33
Meena,92
name,marks
Ravi,45
Tara,67find or findstr?
Use findstr. It is more capable and needs less punctuation. find remains useful for its /c count, and you will meet it in older batch files.
On Linux and the Mac, the matching tools are cat, less, head and tail and grep.
Examples shown with output were run on 12 November 2026 in a practice folder: Windows commands in cmd.exe on Windows 11, Linux commands with the GNU tools of Git Bash. The folder path and user name were replaced with made-up ones. Commands marked "not run here" are shown as you would type them.
This is an independent learning site. It is not connected with Microsoft, Apple or any Linux distribution. Windows, macOS and other names belong to their owners. Try commands first in a practice folder, never on files you cannot afford to lose.