2013-12-11 10:23:59 +00:00
|
|
|
# find
|
|
|
|
|
2024-02-14 20:25:13 +00:00
|
|
|
> Find files or directories under a directory tree, recursively.
|
2021-04-17 16:15:37 +01:00
|
|
|
> More information: <https://manned.org/find>.
|
2013-12-11 10:23:59 +00:00
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
- Find files by extension:
|
2013-12-11 10:23:59 +00:00
|
|
|
|
2016-11-26 15:51:12 +00:00
|
|
|
`find {{root_path}} -name '{{*.ext}}'`
|
2013-12-11 10:23:59 +00:00
|
|
|
|
2021-05-16 20:06:51 +01:00
|
|
|
- Find files matching multiple path/name patterns:
|
2018-11-15 21:33:41 +00:00
|
|
|
|
2021-08-25 16:45:40 +01:00
|
|
|
`find {{root_path}} -path '{{**/path/**/*.ext}}' -or -name '{{*pattern*}}'`
|
2018-11-15 21:33:41 +00:00
|
|
|
|
2019-06-24 03:43:25 +01:00
|
|
|
- Find directories matching a given name, in case-insensitive mode:
|
2018-08-26 05:49:15 +01:00
|
|
|
|
2020-04-15 17:51:26 +01:00
|
|
|
`find {{root_path}} -type d -iname '{{*lib*}}'`
|
2018-08-26 05:49:15 +01:00
|
|
|
|
2019-06-24 03:43:25 +01:00
|
|
|
- Find files matching a given pattern, excluding specific paths:
|
2015-12-28 09:43:58 +00:00
|
|
|
|
2019-06-24 03:43:25 +01:00
|
|
|
`find {{root_path}} -name '{{*.py}}' -not -path '{{*/site-packages/*}}'`
|
A bunch of new pages:
common/: dig, gzip, rm, sort, zfs, zpool
linux/: apt-get, shutdown
osx/: airport, caffeinate, diskutil, networksetup open, pgrep, qlmanage, say, shutdown, sysctl, system_profiler
Edits to existing pages:
curl: Added simple download example
find: Added iname and size exmaples
grep: Edited -c description
ps: Added wide lines example
ssh: edited -D description, added simple port forwarding example
unzip: added list option
2014-02-10 20:36:05 +00:00
|
|
|
|
2023-07-27 16:42:45 +01:00
|
|
|
- Find files matching a given size range, limiting the recursive depth to "1":
|
A bunch of new pages:
common/: dig, gzip, rm, sort, zfs, zpool
linux/: apt-get, shutdown
osx/: airport, caffeinate, diskutil, networksetup open, pgrep, qlmanage, say, shutdown, sysctl, system_profiler
Edits to existing pages:
curl: Added simple download example
find: Added iname and size exmaples
grep: Edited -c description
ps: Added wide lines example
ssh: edited -D description, added simple port forwarding example
unzip: added list option
2014-02-10 20:36:05 +00:00
|
|
|
|
2022-10-07 15:00:29 +01:00
|
|
|
`find {{root_path}} -maxdepth 1 -size {{+500k}} -size {{-10M}}`
|
2015-12-27 05:52:17 +00:00
|
|
|
|
2019-06-24 03:43:25 +01:00
|
|
|
- Run a command for each file (use `{}` within the command to access the filename):
|
2015-12-27 05:52:17 +00:00
|
|
|
|
2024-01-25 02:00:15 +00:00
|
|
|
`find {{root_path}} -name '{{*.ext}}' -exec {{wc -l}} {} \;`
|
2015-12-30 18:43:58 +00:00
|
|
|
|
2024-01-25 02:00:15 +00:00
|
|
|
- Find all files modified today and pass the results to a single command as arguments:
|
2021-05-16 20:06:51 +01:00
|
|
|
|
2024-01-25 02:00:15 +00:00
|
|
|
`find {{root_path}} -daystart -mtime {{-1}} -exec {{tar -cvf archive.tar}} {} \+`
|
2021-05-16 20:06:51 +01:00
|
|
|
|
2024-07-21 09:26:14 +01:00
|
|
|
- Find empty files (0 byte) or directories and delete them verbosely:
|
2017-03-10 14:48:29 +00:00
|
|
|
|
2024-07-21 09:26:14 +01:00
|
|
|
`find {{root_path}} -type {{f|d}} -empty -delete -print`
|