find

Find files by name or type, in a folder and every folder inside it.

>_ Try it: a simulated Linux, right here
Loading the terminal…

Examples

  • find . -name "*.log"
  • find . -name "*.js"
  • find . -type d
  • find . -maxdepth 1 -type f
  • find /etc -name "*release*"

How it works

find walks a folder and everything inside it, and prints the paths that match your tests. Start with where to look (. means here), then say what to look for.

Put patterns like *.log in quotes, so the shell passes them to find instead of expanding them itself.

Syntax

find [FOLDER] [TEST]...

Options

OptionWhat it does
-namenames that match a pattern (* = anything)
-inamethe same, ignoring upper/lower case
-type fonly files
-type donly folders
-maxdepthhow many levels deep to go

Good to know

  • Tests add up: -name "*.log" -type f means both.
  • Searching from / checks the whole disk: give a closer folder when you can.