What's the Bash command recent files?

3

I want to find all files that are:

  • recent
  • do not end in .class
  • no directories

This is what I have attempted but it is not working:

find . \( -atime -1 -a \! -type d -a \! -name '.class' \) -ls

I simplified it to this:

find . -atime -1 -ls

But it is still picking up things from January and earlier. What is going wrong here?

sixtyfootersdude

Posted 2010-02-10T17:43:20.893

Reputation: 6 399

-a (and) is implied so you can omit those (and the parentheses). You probably also want a "" in the name spec: `! -name '.class'` – Paused until further notice. – 2010-02-10T20:41:59.140

I see you've already done that here: http://superuser.com/questions/107201/how-can-i-script-making-a-backup-of-recently-modified-files-in-bash

– Paused until further notice. – 2010-02-10T20:45:37.560

Answers

4

You probably want either -mtime or -ctime. -atime checks the access time, which includes accessing the file metadata. So doing a ls (or a find -atime) will update the access time. -mtime is the time the file contents were last modified and -ctime is the last time the "status" was changed, which I think is the file metadata (permissions, etc).

KeithB

Posted 2010-02-10T17:43:20.893

Reputation: 8 506

1

Solutions use:

find . -ctime -1 -ls

sixtyfootersdude

Posted 2010-02-10T17:43:20.893

Reputation: 6 399