简体   繁体   中英

How to list files that are not accessed for particular mins or days using linux find command?

I created a file t3 under /praveen/sf and used below command to find the files that are not accessed (i am actually looking for t3 file)

$ find praveen -atime +1 -exec grep -iw -r 'vpc' {} \;

But I did not get any output, so I used below command

$ find praveen -atime -1 -exec grep -iw -r 'vpc' {} \;

praveen/sf/t3:NACL referes to Network Access Control Lists, which is actually a security layer of our Virtual Private Cloud (VPC).
praveen/sf/t3:NACL referes to Network Access Control Lists, which is actually a security layer of our Virtual Private Cloud (VPC).
NACL referes to Network Access Control Lists, which is actually a security layer of our Virtual Private Cloud (VPC).

And I read like -atime -1 displays files which are accessed by more than 1 day ago and -atime +1 displays files which are not accessed 1 day ago.

But the above commands did not throw output as I had read.

Please help.

Your understanding of find 's -atime usage is not correct. -atime -1 displays files which were last accessed less than 1 day (24 hours) ago, and -atime +1 displays files which were last accessed more than 24 hours ago. To see files NOT accessed within the last 24 hours in the current dir, you can run this find command:

find . -type f -atime +1 | xargs ls -ld

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM