diff --git a/README.md b/README.md index c0203a8..e2c990e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really warrant a full blog post. These are mostly things I learn by pairing with smart people at [Hashrocket](http://hashrocket.com/). -_414 TILs and counting..._ +_415 TILs and counting..._ --- @@ -365,6 +365,7 @@ _414 TILs and counting..._ - [Create A File Descriptor with Process Substitution](unix/create-a-file-descriptor-with-process-substitution.md) - [Curling With Basic Auth Credentials](unix/curling-with-basic-auth-credentials.md) - [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md) +- [Exclude A Directory With Find](unix/exclude-a-directory-with-find.md) - [File Type Info With File](unix/file-type-info-with-file.md) - [Find Newer Files](unix/find-newer-files.md) - [Get The Unix Timestamp](unix/get-the-unix-timestamp.md) diff --git a/unix/exclude-a-directory-with-find.md b/unix/exclude-a-directory-with-find.md new file mode 100644 index 0000000..e872b31 --- /dev/null +++ b/unix/exclude-a-directory-with-find.md @@ -0,0 +1,19 @@ +# Exclude A Directory With Find + +Using `find` is a handy way to track down files that meet certain criteria. +However, if there are directories full of irrelevant files, you may end up +with a lot of noise. What you want to do is exclude or ignore such +directories. For example, you probably don't want `find` to return results +from the `.git` directory of your project. + +Specific directories can be excluded by combining the `-not` and `-path` +arguments. + +For instance, to see all files modified within the last 10 days, but not +including anything in the `.git` directory, run the following: + +```bash +$ find . -type f -not -path './.git/*' -ctime -10 +``` + +[source](http://stackoverflow.com/questions/4210042/exclude-directory-from-find-command)