ShareYourGroupShareYourGroupCommands

Windows commands

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

Windows Command Prompt
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,67

type 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.

Windows Command Prompt not run here
more log.txt

It 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.

Windows Command Prompt
C:\Users\asha\demo>find "ERROR" log.txt

---------- LOG.TXT
09:05 ERROR Printer not found
09:07 ERROR Printer not found

Its switches:

SwitchEffect
/iignore capital and small letters
/vshow the lines that do not contain the text
/ccount the matching lines instead of showing them
/nshow line numbers
Windows Command Prompt
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 space

Counting lines in a file is a common trick: find /c /v "" counts the lines that do not contain nothing, which is all of them.

Windows Command Prompt
C:\Users\asha\demo>find /c /v "" marks.csv

---------- MARKS.CSV: 6

findstr does everything find does and more. It needs no quotation marks for a single word, searches several files at once, and understands patterns.

Windows Command Prompt
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 space

Note 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:.

Windows Command Prompt
C:\Users\asha\demo>findstr /c:"Low disk" log.txt
09:10 WARN  Low disk space

Searching many files

Give a wildcard, and each matching line is shown with its file name.

Windows Command Prompt
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.

Windows Command Prompt
C:\Users\asha\demo>findstr /s /m /i "report" *.txt
log.txt
old\draft.txt
report.txt

Useful findstr switches

SwitchEffect
/iignore case
/nshow line numbers
/ssearch subfolders
/mprint only the names of matching files
/vshow lines that do not match
/c:"text"search for the exact phrase
/bmatch only at the beginning of a line
/ematch only at the end of a line
/rtreat 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.

Windows Command Prompt
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 found

That 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.

Windows Command Prompt
C:\Users\asha\demo>dir /b | findstr /i ".txt"
log.txt
notes.txt
report.txt

The 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 >.

Windows Command Prompt
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 found

sort

sort puts the lines of a file in alphabetical order, and /r reverses it.

Windows Command Prompt
C:\Users\asha\demo>sort marks.csv
Asha,78
Kabir,33
Meena,92
name,marks
Ravi,45
Tara,67

find 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.