find
Find files by name or type, in a folder and every folder inside it.
>_ Try it: a simulated Linux, right herenothing runs on your computer
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
| Option | What it does |
|---|---|
-name | names that match a pattern (* = anything) |
-iname | the same, ignoring upper/lower case |
-type f | only files |
-type d | only folders |
-maxdepth | how many levels deep to go |
Good to know
- Tests add up:
-name "*.log" -type fmeans both. - Searching from
/checks the whole disk: give a closer folder when you can.