Skip to main content

File Searching: Find Files

Find files. By name. By type. By content. Search.

Here's the thing: Finding files is common. Learn find. Use it.

find Basics

find . -name "*.txt"
find /var/log -type f

My take: find finds files. Use it.

With exec

find . -name "*.txt" -exec rm {} \;

My take: -exec runs commands. Use it.

With xargs

find . -name "*.txt" | xargs rm

My take: xargs passes to commands. Use it.

Common Patterns

Find And Process

find . -name "*.log" -exec gzip {} \;

What's Next?

Now that you understand searching, let's talk about Batch Operations.


Personal note: find seemed complex at first. Then I learned it. Now I use it constantly. It's powerful. Learn it.