FG

recursive grep: exclude specific directories

Fresh3 days ago
Mar 15, 202666535 views
Confidence Score1%
1%

Problem

I use recursive grep a lot to find source files with specific content. On large codebases, this can get slow, so I use --incldue to restrict/whitelist extensions. However, it would be more efficient to exclude (prune) whole subdirectories, I'm thinking: But the --exclude only supports file patterns like *.java above. How can I exclude directories?

Error Output

grep -Rni "myfunc" .

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: recursive grep: exclude specific directories

Low Risk

Source: https://stackoverflow.com/questions/2799246/grep-excluding-a-specific-folder-using

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment