Skip to content

Commit c4de04b

Browse files
committed
Add Exclude A Directory With Find as a unix til
1 parent 93a85fd commit c4de04b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
77
warrant a full blog post. These are mostly things I learn by pairing with
88
smart people at [Hashrocket](http://hashrocket.com/).
99

10-
_414 TILs and counting..._
10+
_415 TILs and counting..._
1111

1212
---
1313

@@ -365,6 +365,7 @@ _414 TILs and counting..._
365365
- [Create A File Descriptor with Process Substitution](unix/create-a-file-descriptor-with-process-substitution.md)
366366
- [Curling With Basic Auth Credentials](unix/curling-with-basic-auth-credentials.md)
367367
- [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md)
368+
- [Exclude A Directory With Find](unix/exclude-a-directory-with-find.md)
368369
- [File Type Info With File](unix/file-type-info-with-file.md)
369370
- [Find Newer Files](unix/find-newer-files.md)
370371
- [Get The Unix Timestamp](unix/get-the-unix-timestamp.md)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Exclude A Directory With Find
2+
3+
Using `find` is a handy way to track down files that meet certain criteria.
4+
However, if there are directories full of irrelevant files, you may end up
5+
with a lot of noise. What you want to do is exclude or ignore such
6+
directories. For example, you probably don't want `find` to return results
7+
from the `.git` directory of your project.
8+
9+
Specific directories can be excluded by combining the `-not` and `-path`
10+
arguments.
11+
12+
For instance, to see all files modified within the last 10 days, but not
13+
including anything in the `.git` directory, run the following:
14+
15+
```bash
16+
$ find . -type f -not -path './.git/*' -ctime -10
17+
```
18+
19+
[source](http://stackoverflow.com/questions/4210042/exclude-directory-from-find-command)

0 commit comments

Comments
 (0)