find command in unix-like OSes is great. But, it is not helpful in searching for source code files or in searching
inside source code files (when used along with grep). So, we need a specialized command.
scfind, which stands for 'source code find', is a replacement for find command for source code
files. It's ultra light and very fast.
- Install Go version at least 1.25
- Run command:
go install github.com/m-manu/scfind@latest
- Add following line in your
.bashrc/.zshrcfile:export PATH="$PATH:$HOME/go/bin"
Running scfind -h or scfind --help shows this help message:
scfind is a 'find' command for source code files
Usage:
scfind [options] $DIRECTORY_PATH
where,
$DIRECTORY_PATH is path to a readable directory that
you want to scan for source code files
Options:
-h, --help print help and exit
-g, --git-aware respect .gitignore (requires git on PATH)
For more details: https://github.com/m-manu/scfind
scfind ~/Programmingscfind . | xargs grep --color "LinkedHashSet"# Respect .gitignore (and nested repos' gitignores)
scfind -g ~/Programming
scfind --git-aware .go build && go test ./...scfind command traverses file tree with source code awareness in following ways:
- Scans for files with known source code and configuration file extensions (case-insensitive)
- e.g.
.java,.go,.py,.ymletc. - see full list
- e.g.
- Scans for files with certain names (case-sensitive)
- e.g.
postinst,Dockerfileetc. - see full list
- e.g.
- Skips scanning certain directories (case-sensitive)
- e.g.
.git,.idea,.gradleetc. - see full list
- e.g.
- Skips scanning certain directories with specific peer files (case-sensitive)
- e.g. skip
buildsubdirectory whenbuild.gradleexists in the same directory etc. - see full list
- e.g. skip
Optionally, with -g / --git-aware, when git is available and the search root (or a nested subdirectory) is a
Git working tree, scfind also respects .gitignore (via git ls-files). Without that flag, Git is not consulted at
all. If the flag is set but git is not on $PATH, scfind warns and falls back to the filesystem filters above.