Fossick

Command to Search for Words: grep, findstr, Select-String and an Easier Offline Alternative

· 6 min read

Short answer: The command to search for words inside files is grep on macOS and Linux (for example grep -rni "invoice" ~/Documents), findstr in the Windows Command Prompt (findstr /s /i "invoice" *.txt), and Select-String in PowerShell. All three match exact text and work best on plain-text files, not PDFs or Word documents.

Download Fossick

Free to try (1 folder, 200 files) · US$14.99 to keep · Mac & Windows

You know a word or phrase is in one of your files. You just don't know which file. The command line is a fast, free way to check, and every Windows, Mac and Linux computer already has a tool built in for it.

This guide gives you the exact command to search for words on each system, with copy-ready examples. It also explains where these commands fall short, especially with PDFs, Word documents and scanned pages, and what to use when you remember the idea of a document but not its exact wording.

Fossick search panel ranking documents on this Mac by meaning for a plain-language query
Fossick in action: type what you remember, get the document — entirely on your machine. Get the app.

The Windows command to search for words: findstr

In the Windows Command Prompt, the command to search for words inside files is findstr. Open Command Prompt, move into the folder you want to search with cd, and run:

That last flag matters. Without /c:, findstr treats spaces as OR, so findstr "payment terms" returns lines containing either word. To require two words on the same line, chain searches: findstr /i "budget" notes.txt | findstr /i "forecast".

findstr is quick and always available, but it is old and basic. Its regular-expression support is limited, and it reads files as raw text.

PowerShell Select-String: a more flexible search command

In PowerShell, Select-String is the more capable equivalent of findstr and of grep. It is case-insensitive by default and supports full regular expressions.

Select-String output includes the file name, line number and matching line, which makes it easy to scan results. Like findstr, though, it reads files as text, so it shares the same blind spots with documents.

grep on Mac and Linux (and mdfind on a Mac)

On macOS and Linux, the standard command to search for words in files is grep. Open Terminal and try:

mdfind: grep's document-aware cousin on macOS

Macs also have mdfind, the command-line front end to Spotlight. mdfind -onlyin ~/Documents "quarterly review" searches the Spotlight index rather than raw bytes. Because Spotlight indexes files and their content, mdfind can often find words inside PDFs and Word files that grep misses. Windows has a similar index behind File Explorer search, and Windows Search indexing can be configured to include file contents, though it is not exposed through findstr.

Why search commands miss PDFs, Word docs and scans

grep, findstr and Select-String read the raw bytes of a file, so they only work reliably when the words are stored as plain text.

That breaks down with common document formats:

There is a second, quieter limit: exact matching. If the contract says "termination for convenience" and you search "cancel the agreement", no keyword tool will connect them. You have to guess the author's exact words. That is the core difference covered in semantic search vs keyword search.

Workarounds exist, such as converting files to text first or using document-specific tools, but they add steps and still leave you guessing at wording.

Which search method to use when

Use command-line tools for plain-text files and exact strings, and a document-aware or meaning-based tool for PDFs, Office files and scans.

MethodPlatformReads PDF/Word?Matches byScanned pages
findstrWindows (cmd)NoExact textNo
Select-StringWindows (PowerShell)NoText or regexNo
grepMac, LinuxNoText or regexNo
mdfindMacOften, via SpotlightKeywordsVaries
FossickWindows, MacYesMeaningYes, on-device OCR

If you are searching log files, code, CSVs or notes in Markdown, grep or Select-String is hard to beat. If your files are mostly contracts, reports and scanned letters, the command line will keep coming up empty.

An offline alternative that searches by meaning

If you want to find documents by what they say rather than their exact words, an on-device semantic search app does that without uploading anything.

Fossick is a desktop app for Windows and Mac that searches your local documents by meaning, entirely offline. You point it at a folder, it indexes the contents, and then you type what you remember, such as "the letter about late delivery penalties", to find the matching documents. Semantic search aims to match the meaning of a query rather than its exact keywords, which is exactly the gap grep and findstr leave.

What it handles that the commands don't:

What stays on your computer

Text extraction, OCR, embedding and search all run on your device using a small local model (all-MiniLM-L6-v2, about 22 MB). Documents are never uploaded, and it works with Wi-Fi off; only licensing touches the internet. That matters if your files are confidential.

It is also worth being clear about what it is not: Fossick is search, not chat. There is no chatbot, no generative AI and no summaries. It returns your documents; you read them.

You can download it and try it free with no sign-up or card on 1 folder of up to 200 files. The full app is a one-time US$14.99 purchase with all future updates and a 14-day money-back guarantee; see pricing. Keep grep and Select-String for text files and exact strings, and use meaning-based search for everything else.

Frequently asked questions

How do I search for an exact phrase with grep or findstr?

With grep, wrap the phrase in quotes: grep -rni "payment terms" .. With findstr, use the /c: flag, as in findstr /s /i /c:"payment terms" *.txt, because without it findstr treats each space-separated word as an alternative.

How do I search for multiple words at once from the command line?

For either word, use grep -E "budget|forecast" on Mac or Linux, findstr "budget forecast" in Command Prompt, or Select-String -Pattern "budget","forecast" in PowerShell. To require both words on the same line, pipe one search into another, for example grep -i budget file.txt | grep -i forecast.

Can findstr or grep search inside Word documents and PDFs?

Not reliably. Word .docx files are compressed archives and most PDFs store text in compressed streams, so raw-text tools usually miss the words. On a Mac, mdfind uses the Spotlight index and often works better; for scanned files you need a tool that runs OCR.

Is there a way to search my documents by meaning without uploading them?

Yes. On-device semantic search apps index your files locally and compare meaning on your own computer. Fossick, for example, runs extraction, OCR, embedding and search entirely on your device and works with Wi-Fi off, so documents never leave your machine.