1

So, I'm trying to get all files older than 40 days. (hence the -mtime -40), but can't find because some files have invalid predicates. (Need to find all files whether in current or descendant.

$ find . -name * -mtime -40 > FILE_LIST
find: invalid predicate `-file-name.xls'

And then...

$ find ./* -name * -mtime -40 > FILE_LIST
find: invalid predicate `-file-name.xls'

And neither of these seem to do it.

2 Answers 2

1

I think the problem is that the * in your -name * is being expanded to a file list by the shell which is then passed to find on it's command line. The find command then parses the command line and finds the -file-name.xls which it tries to interpret as a command line argument.

try

find .  -mtime -40 > FILE_LIST

which should do what you want.

3
  • This did exactly what I needed :). I guess I tried to bite off more upfront than I needed to. Thanks for the great explanation as well
    – Jeff Ancel
    Jan 19, 2012 at 19:13
  • this works since -name * doesn't do anything in this case (since it means "every possible name", its not changing the output. Note that if you DID need to do something similar you should single-quote the * so that the shell doesn't try to do this expansion. so find . -name '*' -mtime -40 would have worked for you.
    – stew
    Jan 19, 2012 at 19:26
  • @stew: yup <!-- filler
    – user9517
    Jan 19, 2012 at 19:36
1

AHHHH....If you read the man page -mtime -40 will give you files LESS THAN 40 days old. Isn't what you want to do is this:

 find . -mtime +40 >FILE_LIST

if you want to find/list files GREATER THAN 40 days old.

1
  • You're right, the above post should be modified. In my case, I did do +40, and the explanation was good above and it was resolved.
    – Jeff Ancel
    Jan 20, 2012 at 17:32

You must log in to answer this question.

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