last 5 files

Hi,
Is there a way that we can get the last files (ex, recent 5 files) that came into a directory. Thanks.

In what sense? the last deleted files? recover them? have them sent to you? a list of files that were last cp'd to the directory?

These are kind of log files and I need the last 5 files.

are they still in the directory? do you only want the names, or do you want the files themselves?

Names would be fine.

I am afraid that i know of no such technique without your previously having installed some sort of surveilance device (keyloger, directory sniffer, etc.). It is possible to retrieve this information from playing with your FS in ways that are far from humane. If this is not a life-or-death case, i reccomend installing one of the aforementioned tools for future use.

Try this code:

ls -tc some/dir | head -5

It will list the last 5 modified files..

Ah, yes, I apologise, i was a bit ambiguous in my last post. I meant if they had been deleted :slight_smile:

Thanks very much.

I tried

ls -Flt dir| awk '{print $9}' | head -5

but your command is most straight forward.