Source Code GREP (SCGREP)

Why?
grep-like commands on unix-like OSes are great. In fact, a search using grep is faster than the search on your IDE when there is no code index.
But, one key pain? A grep -r scans all files and not just source code files, making them slow. Sometimes, very slow. So, there is a need for a command that can scan only source code files.
What?
scgrep, which stands for 'source code grep', is a lightweight CLI tool that wraps your system's grep command and runs it only against source code files.
It traverses directory trees with source-code awareness — scanning files by known extensions (.go, .java, .py, .yml, etc.) and known filenames (Dockerfile, postinst, etc.), while skipping noise directories like .git, node_modules, build, and .gradle.
All grep flags and patterns are passed through as-is.
Internally, it fans out across multiple goroutines for parallel directory scanning, making it faster than a plain grep -r on large codebases.
How to install?
- Install Go version at least 1.25
- Run command:
go install github.com/m-manu/scgrep@latest
- Add following line in your
.bashrc/.zshrc file:
export PATH="$PATH:$HOME/go/bin"
How to use?
Running scgrep -h shows this help message:
scgrep is a 'find' command for source code files
Usage:
scgrep DIRECTORY_PATH
where,
DIRECTORY_PATH is path to a readable directory that
you want to scan for source code files
For more details: https://github.com/m-manu/scgrep
Examples
scgrep ~/Programming
scgrep . | xargs grep --color "LinkedHashSet"
Which files does it ignore?
scgrep command traverses file tree with source code awareness in following ways:
- Scans for files with known source code and configuration file extensions (case insensitive)
- Scans for files with certain names (case sensitive)
- Skips scanning certain directories (case sensitive)
- Skips scanning certain directories with specific peer files (case sensitive)
- e.g. skip
build sub-directory when build.gradle exists in the same directory etc.
- see full list