Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UNIX script - find files - show dates

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.

like image 287
Thomas Pollock Avatar asked Jan 21 '26 20:01

Thomas Pollock


2 Answers

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.

like image 109
dogbane Avatar answered Jan 24 '26 18:01

dogbane


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
like image 39
Petesh Avatar answered Jan 24 '26 18:01

Petesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!