Find files that do not have “foo” in the path

How to find files that do not have a particular string in the pathname. …

find . ! -path '*foo*' -type f

This will find all files that do not have the string "foo" in their pathnames. Naturally you can add additional exclusions, for example:

find . ! -path '*foo*' ! -path '*bar*' -type f

This finds all files that have neither "foo" nor "bar" in their pathnames.

Advertisements

About Warren Post

So far: Customer support guy, jungle guide, IT consultant, beach bum, entrepreneur, teacher, diplomat, over-enthusiastic cyclist. Tomorrow: who knows?
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s