find Search the file tree
Light · Postcard
102 × 152 mm · PDF
Dark · Postcard
102 × 152 mm · PDF
Ink saver · Postcard
102 × 152 mm · PDF
Light · A4 landscape
297 × 210 mm · PDF
Dark · A4 landscape
297 × 210 mm · PDF
Ink saver · A4 landscape
297 × 210 mm · PDF
Light · A3 landscape
420 × 297 mm · PDF
Dark · A3 landscape
420 × 297 mm · PDF
Ink saver · A3 landscape
420 × 297 mm · PDF
Start here
find . -name '*.txt'
find . -type ffind . -type dfind . -mtime -7
find . -size +10M
find . -maxdepth 1
find . -name '*.log' -delete
find . -type f -exec <cmd> {} +
Concepts
- Start paths where to look
- Options depth, symlinks
- Tests name, type, size, time
- Actions print, exec, delete
Name & Type
find <dir> -name '<glob>'
find <dir> -iname '<glob>'
find <dir> -type f
find <dir> -type d
find <dir> -type l
find <dir> -path '<glob>'
find <dir> -regex '<regex>'
find <dir> -type f,d
find <dir> -xtype l
Size & Time
find <dir> -size +<n>M
find <dir> -size -<n>k
find <dir> -empty
find <dir> -mtime -<n>
find <dir> -mtime +<n>
find <dir> -mmin -<n>
find <dir> -newer <file>
find <dir> -newermt '<date>'
find <dir> -atime +<n>
Owner & Permissions
find <dir> -user <name>
find <dir> -group <name>
find <dir> -perm 644
find <dir> -perm -u+x
find <dir> -perm /022
find <dir> -nouser
Depth & Pruning
find <dir> -maxdepth <n>
find <dir> -mindepth <n>
find <dir> -name <d> -prune -o -print
find <dir> -xdev
find -L <dir>
find <dir> -name <f> -print -quit
Combining
find <dir> -name '*.c' -o -name
'*.h'
find <dir> ! -name '<glob>'
find <dir> \( <a> -o <b> \)
<c>
find <dir> <a> , <b>
Actions
find <dir> -print
find <dir> -print0
find <dir> -exec <cmd> {} \;
find <dir> -exec <cmd> {} +
find <dir> -ok <cmd> {} \;
find <dir> -execdir <cmd> {} \;
find <dir> -delete
find <dir> -printf '<fmt>'
find <dir> -ls
xargs
find <dir> -print0 | xargs -0 <cmd>
xargs -0 -n <n> <cmd>
xargs -0 -P <n> <cmd>
xargs -0 -I {} <cmd> {}
xargs -r <cmd>
xargs -0 -a <file> <cmd>
Recipes
find /var/log/app -name '*.log' -mtime +30 -print# check the list, then swap in -deletefind /var/log/app -name '*.log' -mtime +30 -delete
find . -name '*.md' -print0 \ | xargs -0 sed -i 's/<old>/<new>/g'
find . -name .git -prune -o -type f \ -exec grep -l '<text>' {} +
find . -type f -printf '%s %p\n' \ | sort -nr | head



