Quantcast
Channel: Linux: using find to locate files older than - Server Fault
Viewing all articles
Browse latest Browse all 12

Answer by Richard Holloway for Linux: using find to locate files older than

$
0
0

You could use a script like this

#!/bin/bashif [ $# -ne 1 ];then  when="today"else  when=` date -d "$1"+"%s" `finow=`date +"%s"`seconds=`echo "$when - $now" | bc`minutes=`echo "$seconds / 60 " | bc `find . -cmin $minutes -print

Save it in your $PATH as "newerthan" and make it executable.

Then you can find file modified after a certain date like this:

newerthan "2010-03-10"

or

newerthan "last year"

or

newerthan "yesterday"

That should do what you want. I don't think there is a built in way to achieve this otherwise.


Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>