To understand basics like error redirection and paths refer to [Things to Know About Linux](Things%20to%20Know%20About%20Linux.md)
# Usage
```bash
find /etc /usr -regex '^\(/usr\|/etc\).*completion.*sh' -regextype posix-extended
```
```bash
find <path> <conditions> <actions>
```
## Common Examples
When wanting to use exact case use ```-name```.
When wanting to ignore case use ```-iname```.
### Find a specific directory
```bash
find /path_to_search -type d -iname 'dir_name' 2>/dev/null
```
### Find a directory containing a string
```bash
find /path_to_search -type d -iname '*string*' 2>/dev/null
```
### Find a specific
```bash
find /path_to_search -type f -iname 'file_name' 2>/dev/null
```
### Find a file containing a string
```bash
find /path_to_search -type f -iname '*string*' 2>/dev/null
```
### Search multiple locations
```bash
find /first_path_to_search /second_path_to_search /etc -type f -iname '*string*' 2>/dev/null
```
### Find executable files
```bash
find /path_to_search -executable
```
## Conditions
```bash
-name "*.c"
```
```bash
-user jonathan
-nouser
```
```bash
-type f # File
-type d # Directory
-type l # Symlink
```
```bash
-depth 2 # At least 3 levels deep
-regex PATTERN
```
```bash
-size 8 # Exactly 8 512-bit blocks
-size -128c # Smaller than 128 bytes
-size 1440k # Exactly 1440KiB
-size +10M # Larger than 10MiB
-size +2G # Larger than 2GiB
```
```bash
-newer file.txt
-newerm file.txt # modified newer than file.txt
-newerX file.txt # [c]hange, [m]odified, [B]create
-newerXt "1 hour ago" # [t]imestamp
```
## Access time conditions
```bash
-atime 0 # Last accessed between now and 24 hours ago
-atime +0 # Accessed more than 24 hours ago
-atime 1 # Accessed between 24 and 48 hours ago
-atime +1 # Accessed more than 48 hours ago
-atime -1 # Accessed less than 24 hours ago (same a 0)
-ctime -6h30m # File status changed within the last 6 hours and 30 minutes
-mtime +1w # Last modified more than 1 week ago
```
These conditions only work in MacOS and BSD-like systems (no GNU/Linux support).
## Condition flow
```bash
\! -name "*.c"
\( x -or y \)
```
## Actions
```bash
-exec rm {} \;
-print
-delete
```
## Examples
```bash
find . -name '*.jpg'
find . -name '*.jpg' -exec rm {} \;
```
```bash
find . -newerBt "24 hours ago"
```
```bash
find . -type f -mtime +29 # find files modified more than 30 days ago
```
### Usage
```bash
find <path> <conditions> <actions>
```
## Conditions
```bash
-name "*.c"
```
```bash
-user jonathan
-nouser
```
```bash
-type f # File
-type d # Directory
-type l # Symlink
```
```bash
-depth 2 # At least 3 levels deep
-regex PATTERN
```
```bash
-size 8 # Exactly 8 512-bit blocks
-size -128c # Smaller than 128 bytes
-size 1440k # Exactly 1440KiB
-size +10M # Larger than 10MiB
-size +2G # Larger than 2GiB
```
```bash
-newer file.txt
-newerm file.txt # modified newer than file.txt
-newerX file.txt # [c]hange, [m]odified, [B]create
-newerXt "1 hour ago" # [t]imestamp
```
## Access time conditions
```bash
-atime 0 # Last accessed between now and 24 hours ago
-atime +0 # Accessed more than 24 hours ago
-atime 1 # Accessed between 24 and 48 hours ago
-atime +1 # Accessed more than 48 hours ago
-atime -1 # Accessed less than 24 hours ago (same a 0)
-ctime -6h30m # File status changed within the last 6 hours and 30 minutes
-mtime +1w # Last modified more than 1 week ago
```
These conditions only work in MacOS and BSD-like systems (no GNU/Linux support).
## Condition flow
```bash
\! -name "*.c"
\( x -or y \)
```
## Actions
```bash
-exec rm {} \;
-print
-delete
```
## Examples
```bash
find . -name '*.jpg'
find . -name '*.jpg' -exec rm {} \;
```
```bash
find . -newerBt "24 hours ago"
```
```bash
find . -type f -mtime +29 # find files modified more than 30 days ago
```
```bash
find / -writable -type f -not -path '*/proc/*' -not -path '*/dev/*' 2>/dev/null
```