FG
💻 Software

How to ignore certain filenames using "find"?

Fresh7 days ago
Mar 15, 2026218825 views
Confidence Score1%
1%

Problem

One of my favorite BASH commands is: which searches the contents of all of the files at and below the current directory for the specified SearchString. As a developer, this has come in handy at times. Due to my current project, and the structure of my codebase, however, I'd like to make this BASH command even more advanced by not searching any files that are in or below a directory that contains ".svn", or any files that end with ".html" The MAN page for find kind of confused me though. I tried using -prune, and it gave me strange behavior. In an attempt to skip only the .html pages (to start), I tried : and did not get the behavior I was hoping for. I think I might be missing the point of -prune. Could you guys help me out? Thanks

Error Output

find . -name '*.*' -exec grep 'SearchString' {} /dev/null \;

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to ignore certain filenames using "find"?

Low Risk

You can use the negate (!) feature of find to not match files with specific names: So if the name ends in .html or contains .svn anywhere in the path, it will not match, and so the exec will not be executed.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment