Monday, October 21, 2013

Find and Time

I have never been particularly good at remembering find's arguments related to times/dates/etc. So this is going to be a bit of a cheat sheet for myself. Find *~ files modified older than today:
find . -name \*~ ! -newermt `date +%F -s yesterday`
Find *~ files modified newer than yesterday:
find . -name \*~ -newermt `date +%F -s yesterday`
Find *~ files between certain days:
find . -name \*~ -newermt `date +%F -s '14 days ago'` ! -newermt `date +%F -s '7 days ago'`