scgrep

command module
v0.0.0-...-02891fc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

README

Source Code GREP (SCGREP)

Build and test Go Report Card Go Reference License

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?

  1. Install Go version at least 1.25
  2. Run command:
    go install github.com/m-manu/scgrep@latest
    
  3. 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:

  1. Scans for files with known source code and configuration file extensions (case insensitive)
    • e.g..java, .go, .py, .yml etc.
    • see full list
  2. Scans for files with certain names (case sensitive)
    • e.g. postinst, Dockerfile etc.
    • see full list
  3. Skips scanning certain directories (case sensitive)
    • e.g. .git, .idea, .gradle etc.
    • see full list
  4. 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

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL