Windows
Linux
Text Processing
Search
Windows findstr equivalent in Linux
Searches for text patterns inside files. One of the most-used Linux commands.
Windows
→
findstr
Linux equivalents
grep
grep
grep
Overview
What this command does
Searches for text patterns inside files. One of the most-used Linux commands.
Migration tip:
grep supports regular expressions, making it far more powerful than Windows' findstr. The pipe operator | lets you chain it with other commands.Practical tasks
Common use cases
Search text within files
Searches for text patterns inside files. One of the most-used Linux commands.
grep -r
Search recursively in all files
grep -i
Case-insensitive search
grep -n
Show line numbers
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
grep "error" logfile.txt
grep -i "error" logfile.txt
grep -rn "TODO" ~/Projects/
ps aux | grep nginx
cat access.log | grep "404"
Walkthrough
Examples with explanations
# Windows: findstr "error" logfile.txt
grep "error" logfile.txt # search for 'error'
grep -i "error" logfile.txt # case-insensitive
grep -rn "TODO" ~/Projects/ # find TODOs in all files
# Super useful: pipe into grep:
ps aux | grep nginx # find nginx process
cat access.log | grep "404" # find all 404 errors
Reference
Common options and variations
| Command or option | Use |
|---|---|
grep -r | Search recursively in all files |
grep -i | Case-insensitive search |
grep -n | Show line numbers |
grep -v | Show lines that do NOT match |
grep -c | Count matching lines only |
grep -l | Show only filenames that match |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | grep |
Same command on this distribution. |
| Fedora | same command | grep |
Same command on this distribution. |
| Arch | same command | grep |
Same command on this distribution. |
Keep learning