I have a little bit of code that I use to get an MD5 sum of the most recently modified file time

find ./media -type f -printf "%TY-%Tm-%Td %TT %p \n" | sort | more | tail -1 | md5 -r | awk '{print $1}'

I use it for generating unique keys for my CDN files, the logic behind this is if a file changes the key changes so the files are un-cached and reloaded.

Anyway, when I try to run that on my Mac I get the error '-printf unknown option'
I looked through the man page but couldn't find anything similar, how do I get this too work?

2 Answers 2


printf is specific to GNU find and not available on OS X's find by default.

Install findutils on your Mac, e.g. using Homebrew using the following command:

brew install findutils

You can alternatively use Macports or Fink, they likely also have this package available.

To actually use gnu find you will need to use gfind since find will still link to OSX's find located in /usr/bin/find.

Homebrew comes with a tap for cases where system commands are duplicated by the commands installed via homebrew.
Simply do brew tap homebrew/dupes, and then for above example brew install findutils.
Now you should be able to use homebrews find command without having to explicitly call it via gfind.

  • 3
    ...and once you've installed findutils, the command that is installed is named gfind (gnu find)
    – Quentin
    Nov 29, 2013 at 19:24
  • brew tap homebrew/dupes homebrew/dupes was deprecated. This tap is now empty and all its contents were either deleted or migrated.
    – JJS
    Oct 16, 2021 at 0:51

You could use the -ls flag instead to get the same information (and then some), which might work just as well for your purposes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .