Show Menu
Cheatography

GNU Find Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Locations to search

one location
/usr/­bin­/find [locat­ion1]
two locations
/usr/­bin­/find [locat­ion1] [locat­ion2]
N locations
/usr/­bin­/find [locat­ion1] [locat­ion2] ... [locat­ionN]
can specify 0 or more locations to search
if 0 locations are specified then the current directory will be searched
locations separated by space character
 

Search by name

case-s­ens­itive
-name [name-­con­tai­nin­g-w­ild­cards]
case-i­nse­nsitive
-iname [name-­con­tai­nin­g-w­ild­cards]
searching by name only searches the name of the end file, not of the parent folders in that file's path
names can contain wildcards
for example, to search for files ending in .conf I would use -iname "­*.c­onf­"

Search by time

creati­on-time (days)
-ctime [days]
creati­on-time (minutes)
-cmin [mins]
modifi­cat­ion­-time (days)
-mtime [days]
modifi­cat­ion­-time (minutes)
-mmin [minutes]
Preceed the number of minutes or days with + to mean "­greater than"
Preceed the number of minutes or days with - to mean "less than"

Examples
to find files modified in the last two days use -mtime -2
to find files created more than 30 mins ago use -cmin +30
 

Searching by path

case-s­ens­itive
-path [path-­con­tai­nin­g-w­ild­cards]
case-i­nse­nsitive
-ipath [path-­con­tai­nin­g-w­ild­cards]
searching by path searches both the name of the end file as well as the names of the parent folders in that file's path
paths can contain wildcards
for example, to search for files which have parent folders somewhere along their path named "­sal­es" or "­mar­ket­ing­" that end in ".da­t" I would use: -ipath "­*s­ale­s*.da­t" -or -ipath "­*m­ark­eti­ng­*.d­at"