Tech Reflect
  • Home
  • About This Site
  • Contact Me
  • Search Icon

Tech Reflect

Reflecting on 25 years in tech

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:

Xcode nuclear option
Quick open files of a certain type
Ultra high volume email workflow
Flow control in bash
More efficient process killing
Curly braces on the command line

geeky, macOS tips

Post navigation

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

Follow Me

Get Monthly Updates

About Me

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

Contact Me

My Other Blogs

  • Free Range Parrots
  • Plucky Tree (personal)
  • Little Dinosaur
  • Contact Me

Recent Posts

  • Getting paid to watch porn
  • Is App Library for me?
  • Tim Cook and the SF Gay Pride Parade
  • The first day we printed something in Mac OS X
  • Except for getting punched by Steve Jobs…

Categories

  • analog (1)
  • apple career (11)
  • apple inside (8)
  • apple stories (18)
  • bertrand serlet (3)
  • essays (15)
  • geeky (21)
  • iOS tips (3)
  • macOS tips (37)
  • personal (7)
  • products (3)
  • prototypes (2)
  • scott forstall (6)
  • scripting (1)
  • steve jobs (11)
  • tim cook (1)
  • workplace (14)

Archives

  • January 2021
  • December 2020
  • October 2020
  • August 2020
  • July 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017

Most Liked Content

  • Why I left Apple (2019)
  • Aperture: Senior QA (2004-2005)
  • The last time I saw Steve Jobs
  • Desktop Pictures taken by Steve Jobs
  • How I ended up at Apple (1999)

Get Monthly Updates

About Me

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

Contact Me

My Other Blogs

  • Free Range Parrots
  • Plucky Tree (personal)
  • Little Dinosaur
  • Contact Me
© 2021   All Rights Reserved.