Forever & AlwaysLINUX COMMAND ATLAS

LINUX COMMAND ATLAS · COMMAND GUIDE

Linux find command

Search a directory tree by name, type, age, and other conditions.

find manual

Syntax

Command form
find [STARTING-POINT...] [EXPRESSION]

Common options

8 options
OptionWhat it does
-name PATTERNMatch a filename pattern (case-sensitive).
-iname PATTERNMatch a filename pattern without case sensitivity.
-type TYPEMatch a type such as f (file), d (directory) or l (symlink).
-maxdepth NDescend at most N directory levels.
-mtime NMatch by modification age in 24-hour periods.
-size SIZEMatch files by size, such as +100M or -1k.
-exec COMMAND {} \;Run a command for each match; {} represents the path.
-print0Print paths separated by NUL for safe pipelines.

Usage examples

3 examples

Search a directory tree by name, type, age, and other conditions.

find . -type f -name "*.log"

Find regular files with a .conf name below the current directory.

find . -type f -name '*.conf'

Find files modified within the last seven 24-hour periods.

find /var/log -type f -mtime -7

Notes

GNU find evaluates expressions from left to right. Quote wildcard patterns so the shell does not expand them first; take care with -delete and -exec.