Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux_wiki:find [2015/04/28 09:33] billdozor [Find folders with the most files] |
linux_wiki:find [2019/05/25 23:50] (current) |
||
---|---|---|---|
Line 6: | Line 6: | ||
**Checklist** | **Checklist** | ||
- | * Distro(s): | + | * Distro(s): |
---- | ---- | ||
- | ===== General Syntax ===== | + | ====== General Syntax |
The general syntax of find is: | The general syntax of find is: | ||
Line 26: | Line 26: | ||
---- | ---- | ||
- | ===== Find Examples ===== | + | ====== Find Examples |
Some of the useful find commands that have been " | Some of the useful find commands that have been " | ||
Line 32: | Line 32: | ||
---- | ---- | ||
- | ==== Find folders with the most files ==== | + | ===== Find folders with the most files ===== |
If you run into a situation in which you have high inode usage as seen by 'df -i', the following syntax will show folders with the most files: | If you run into a situation in which you have high inode usage as seen by 'df -i', the following syntax will show folders with the most files: | ||
<code bash> | <code bash> | ||
- | nice find / -mount -printf ' | + | nice find / -mount -printf ' |
</ | </ | ||
Line 44: | Line 44: | ||
* find / = start in the "/" | * find / = start in the "/" | ||
* mount = Do not descend directories on other file systems. | * mount = Do not descend directories on other file systems. | ||
- | * printf ' | + | * printf ' |
* sort = Default sort by starting of line alphabetical | * sort = Default sort by starting of line alphabetical | ||
* uniq -c = Filter matching adjacent lines, prefix lines with the count of occurrences | * uniq -c = Filter matching adjacent lines, prefix lines with the count of occurrences | ||
- | * sort -k 1 -n = Sort via the " | + | * sort -n -k 1 = Sort numerically (-n) via the " |
This will give output with the first column displaying file count and the second column displaying the folder it is in. | This will give output with the first column displaying file count and the second column displaying the folder it is in. | ||
Line 59: | Line 59: | ||
2123 / | 2123 / | ||
</ | </ | ||
+ | |||
---- | ---- | ||
+ | |||
+ | ===== Find, starting in /, all files (type f) owned by rjones ===== | ||
+ | |||
+ | <code bash> | ||
+ | find / -user rjones -type f | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Remove all files owned by rjones ===== | ||
+ | |||
+ | <code bash> | ||
+ | find / -user rjones -type f -exec rm ' | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== Find all files modified in the last 3 days ===== | ||
+ | |||
+ | <code bash> | ||
+ | find / -mtime -3 -type f | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ |