Shell - find files before date

, by  Valentin Murariu

So, we have a production system big-bang and I got files produced before and after the big-bang.

How do I find the files produced before the big-bang ?

TESTFILE=$(mktemp -u)
touch -t 1310122359 ${TESTFILE}
find . ! -newer ${TESTFILE}
rm -rf ${TESTFILE}

- create a temporary file name
- create the file with a timestamp of the big-bang. 1310122359 translates to year 2013 (1310122359), month 10 (1310122359), day 12 (1310122359), hour 23 (1310122359), minute 59 (1310122359)
- find the files older than the test file (! -newer switch for find). You could further process this list of files, i.e. by adding -exec mv {} Archive/  \; to find’s command line
- be nice and remove your empty temporary file

Tada !