Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 9 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.

share|improve this answer
    
...and once you've installed findutils, the command that is installed is named gfind (gnu find) –  Quentin Nov 29 '13 at 19:24

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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