0

I'm trying to set a script to let me know what WordPress files have been modified in the last 3 days, but I get a huge list of every site's backups when I just run:

find /var/websites -mtime -1

How do I exclude all directories with the word backup in them? An example of a path that I'd like to exclude is /var/websites/com.site1/backup and all of its subdirectories.

1 Answer 1

0

Use find in this way:

find /var/websites -type f -mtime -3 -not -path '*/backup/*'

-not -path '*/backup/*' will cause find to ignore the files that have /backup/ in their path. The trailing / in /backup/ is to ensure that this will only consider backup as directory names.

Also note that to get precise result regarding time you should use -mmin instead of -mtime. Check man find to get more idea on this.

3
  • Also note that to get best results you should read man find over and over.
    – waltinator
    Apr 27, 2015 at 18:52
  • @waltinator: Have i put anything that could fail? if so could you please point to it..
    – heemayl
    Apr 27, 2015 at 18:55
  • No, but having the questioner learn about find (and man) is, IMHO, a Good Thing. The "you" I used referred to the original poster.
    – waltinator
    Apr 27, 2015 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .