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 \{\} \;


geeky, macOS tips

Post navigation

NEXT
More efficient process killing
PREVIOUS
Creating command-line tool in Swift
Comments are closed.

Get Monthly Updates

Recent Posts

  • Inserting random email sigs in Mail on iOS
  • Keep Instagram open to finish posting…
  • How I predicted the rise of Twitter, barely used it, and amassed 35,000 followers
  • Apple Books 2022, in pictures
  • Killing one bird with two-and-a-half stones in Mac OS X Mail

Categories

  • analog (1)
  • apple career (12)
  • apple inside (19)
  • apple stories (20)
  • bertrand serlet (3)
  • bugs (3)
  • essays (15)
  • geeky (21)
  • interviews (4)
  • iOS tips (4)
  • Mac OS X (7)
  • macOS tips (36)
  • personal (8)
  • predictions (1)
  • products (5)
  • prototypes (6)
  • scott forstall (7)
  • scripting (2)
  • siri (2)
  • 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)
© 2025   All Rights Reserved.