3

I am running the following command:

find . -atime -30

However in the output, I would like it to display the time stamp of access time. Also would like it to show the user that accessed the file if at all possible.

Can you help?

Thanks.

keyser
  • 18,829
  • 16
  • 59
  • 101
Thomas Pollock
  • 405
  • 1
  • 3
  • 11

3 Answers3

4

Use the printf option of find:

find . -atime -30 -printf '%u %Ac %p\n'

Take a look at man find for the different printf formatting options.

dogbane
  • 266,786
  • 75
  • 396
  • 414
2
find . -atime -30 -print0 | xargs -0 ls -lud

You can't determine who accessed the file, this information is not generally recorded.

Bear in mind that atime is not always updated (depends on the file system mount options).

If you want to restrict the find to just files, then you can do:

find . -atime -30 -a -type f -print0 | xargs -0 ls -lud
Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122
1

Last access doesn't log the user that accessed the file.

find . -atime -30 -exec stat {} +

will give you all the info you can get.

If you don't have GNU find or stat, try what Petesh suggests.

vipw
  • 7,593
  • 4
  • 25
  • 48