Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

printing a file's atime

2 views
Skip to first unread message

Liam Hoekenga

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
does anyone know an easy way to print a file's access time?
preferably something that i could use in conjunction with the
"find" command?

i've been tasked with identifying rarely used files, and while i can do
that with

find . -atime +somenumber -atime -somenumber

it would be cool if i could throw an "-exec somecommand {} \;" on there to
actually show when the file was last accessed.

liam


Mark Montague

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to


Under Solaris, use the -u option to ls:

mozi% echo "Hi" >/tmp/foo
mozi% sleep 300
mozi% cat /tmp/foo
Hi
mozi% ls -l /tmp/foo
-rw------- 1 markmont ffive 3 Oct 19 09:54 /tmp/foo
mozi% ls -lu /tmp/foo
-rw------- 1 markmont ffive 3 Oct 19 10:01 /tmp/foo

If, for some reason this does not work for you, the following Perl
hack (warning! no error checking!) will do it:

mozi% perl -e '$t = localtime((stat($ARGV[0]))[8]), print "$t\n";' /tmp/foo
Thu Oct 19 10:01:28 2000

So,

find . -atime <SOMENUMBER1> -atime <SOMENUMBER2> -exec ls -lu {} \;

-or-

find . -atime <SOMENUMBER1> -atime <SOMENUMBER2> -exec \
perl -e '$t = localtime((stat($ARGV[0]))[8]), print "$t\n";' {} \;

Hope this helps.

Mark Montague
LS&A Information Technology
mark...@umich.edu


Liam Hoekenga

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
Thanks for all the responses, guys.

I've never had reason to print atime before, so i didn't even think to
check the ls manpage. d'oh!

liam

0 new messages