Code snippets, tech tricks and other bits and bobs

« Back to blog

*nix - Locate files modified after specified datetime (CentOS 5)

This is basic stuff, but it took me a little while to find decent instructions and they still needed tweaking so for my own reference as much as anything:

Commands

touch

and
find

Syntax

$ touch -t mmddhhmm /path/to/tmp/file
 $ find /path/to/search/ -newer /path/to/tmp/file -print

[month][day][hour][minutes], so 10:25pm on Apr 19th is

04192225

Example

$ touch -t 04192225 /var/www/vhosts/{domain}/timesearch/findresult.txt
 $ find /var/www/vhosts/{domain}/httpdocs/components/com_community/ -newer /var/www/vhosts/{domain}/timesearch/findresult.txt -print

Output:

/var/www/vhosts/{domain}/httpdocs/components/com_community/controllers/frontpage.php
 /var/www/vhosts/{domain}/httpdocs/components/com_community/templates/agiles_social/activities.index.php
 /var/www/vhosts/{domain}/httpdocs/components/com_community/templates/agiles_social/params.ini

May 11, 2011
Robin Kearney said...
I tend to just print_r the var with the JSON in it, also works. Bit less pretty though!
May 11, 2011
Dave Disaster said...
Damn posterous! Wrong topic again.
Even print_r in pre tags can be a bitch to read if it's a large chunk of JSON. I was happy to do that until I had a massive JSON chunk to deal with...