Skip to main content

Command referencefind

find command (Linux / bash / sh / zsh)

Linuxbashshzshfileintermediate

What it does

Walk directory trees and select entries using tests and actions. When people search for the find command linux examples, they usually want find's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Walk directory trees and select entries using tests and actions.

Syntax

find [PATH...] [EXPRESSION]

Common options

Flag / optionMeaning
-name PATTERNMatch a case-sensitive file name.
-type TYPERestrict matches to files, directories, or another type.
-mtime NMatch by modification age in days.
-exec CMD {} +Run a command with batches of matches.

Practical examples

Find logs

find /var/log -type f -name '*.log'

Locates regular log files below /var/log.

Large files

find . -type f -size +100M

Finds files larger than 100 MiB.

Delete stale temp files

find /tmp -type f -mtime +7 -delete

Deletes files older than seven days after selection.

Linux ↔ Windows equivalent

Closest match: Get-ChildItem (Windows / PowerShell). Enumerate items and child items in filesystem, registry, and other providers.

Common mistakes

  • Failing to quote wildcard patterns, allowing the shell to expand them early.
  • Putting `-delete` before restrictive tests, which can remove too much.

FAQ

What does find do in Linux?

Walk directory trees and select entries using tests and actions.

How do I use find from the terminal?

Start with `find [PATH...] [EXPRESSION]`, then choose only the options needed for the task.

What is a practical find example?

Try `find /var/log -type f -name '*.log'` — Locates regular log files below /var/log.

Can I use find in a shell script?

Yes. find works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.