Tech Reflect
  • Home
  • About This Site
  • Contact me
  • Search Icon
Doing something with the “find” command

Doing something with the “find” command

2017-04-03

The find command is one of those utilities that, if you know it well, is one of the most powerful tools in your toolchest. However, with a man page nearly 600 lines long and somewhat bewildering syntax, it’s very intimidating. Sometimes the simplest options you are looking for can be oddly named or unexpected.

I created a series of examples of how to do some very basic stuff with the find command, which is what most people really want to do. Each example builds on the previous one. Once you get comfortable, then you can look at the man page and add new options one at a time to get the hang of it.

# Find a file that contains the string "banana" in the current directory and all subdirectories
find . -name "*banana*"

# Search case insensitively
find . -iname "*banana*"

# Search only in the current directory
find . -maxdepth 1 -iname "*banana*"

# Search at a specific path rather than the current directory
find ~/Library/Logs -maxdepth 1 -iname "*banana*"

# Find files greater created more than two hours ago
find ~/Library/Logs -maxdepth 1 -iname "*banana*" -ctime +120m

# Delete these files (be careful!)
find ~/Library/Logs -maxdepth 1 -iname "*banana*" -ctime +120m -exec rm -rf \{\} \;

Related Posts:

  • Old Dock tips that are still useful
    Old Dock tips that are still useful
  • Ultra high volume email workflow
    Ultra high volume email workflow
  • Why is my own data least important in search?
    Why is my own data least important in search?

geeky, macOS tips

Post navigation

NEXT
Save time in System Preferences
PREVIOUS
Creating command-line tool in Swift

Get Monthly Updates

Recent Posts

  • Coldplay, synchronicity, and the Steve Jobs’ memorial
  • Just admit QA was right
  • Rising from the ashes: Stage Manager
  • Flower Power and Blue Dalmatian to the rescue?
  • “Why does Mail have to be so fucking complicated?”

Categories

  • analog (1)
  • apple career (11)
  • apple inside (17)
  • apple stories (19)
  • bertrand serlet (3)
  • essays (15)
  • geeky (21)
  • interviews (4)
  • iOS tips (3)
  • Mac OS X (5)
  • macOS tips (37)
  • personal (7)
  • products (5)
  • prototypes (6)
  • scott forstall (7)
  • scripting (1)
  • steve jobs (16)
  • tim cook (1)
  • workplace (15)

Get Monthly Updates

About cricket


Me with Guiness the owl

25 years in tech. I like to write manifestos. I like to offer interesting tips. I like making fun of things. Everyone copes differently.

My Other Blogs

  • Free Range Parrots
  • Plucky Tree (personal)
© 2022   All Rights Reserved.