`find’ Cheat Sheet

The process of searching with `find’ is about combining three things;

  1. The start point for the search
  2. The type of criteria or property that we are going to be evaluating on our search
  3. The specific value of the criteria we want to search against.

Numeric arguments below can be specified as;

  • +n : for greater than n,
  • -n : for less than n,
  • n : for exactly n.

We can also employ wildcards to assist in matching names.

  • -name pattern : the file name which matches the pattern pattern
  • -iname pattern : Like -name, but the match is case insensitive
  • -mmin n : the file’s data was last modified n minutes ago
  • -mtime n : the file’s data was last modified n *24 hours ago
  • -newer file : the file was modified more recently than file
  • -amin n : the file was last accessed n minutes ago.
  • -atime n : the file was last accessed n * 24 hours ago
  • -user uname : the file is owned by user uname
  • -group gname : the file belongs to group gname
  • -executable : matches files which are executable and directories which are searchable
  • -type c : the file is of type c:
    • b block (buffered) special
    • c character (unbuffered) special
    • d directory
    • p named pipe (FIFO)
    • f regular file
    • l symbolic link
    • s socket
  • -size n[cwbkMG] : File uses n units of space (rounding up). The following suffixes can be used:
    • b for 512-byte blocks (this is the default if no suffix is used)
    • c for bytes
    • w for two-byte words
    • k for Kilobytes (units of 1024 bytes)
    • M for Megabytes (units of 1048576 bytes)
    • G for Gigabytes (units of 1073741824 bytes)
  • -perm mode: The files have a specific set of permissions with mode different depending on how we want to access them
    • mode File’s permission bits are exactly mode
    • -mode All of the permission bits mode are set for the file.
    • /mode Any of the permission bits mode are set for the file.