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?

link|improve this question

62% accept rate
feedback

2 Answers

up vote 2 down vote accepted

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.

link|improve this answer
feedback

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.