Linux find Command

About

The find command returns the file paths of files which match the search criteria. Find searches by file name and file meta data (size, time, owner, etc). To search based on file content, use grep.

Syntax:

find <options> <starting path> <expression>
  • options attribute will control the behavior and optimization method of the find process.
  • starting path attribute will define the top level directory where find begins filtering.
  • expression attribute controls the tests that search the directory hierarchy to produce output.

Examples

Find by name

Find all case-insensitive files named linux.odt in or under the / directory:

find / -iname linux.odt

Find all case-sensitive files with the .log extension in or under the /home/username/ directory:

find /home/username/ -name "*.log"

Find all case-sensitive files with the .log extension in or under the current directory:

find . -name *backup*

Name Types

name Case sensitive name.
iname Case insensitive name.

Find by type

find / -type f

File Types

f regular file
d directory
l symbolic link
c character devices
b block devices

Find by size

find / -size +1000MB

Output results to a file

find /etc -type f -name "*.conf" > conf_search.txt

More Resources