[SunHELP] script to find newest file

James Lockwood james at foonly.com
Wed Jul 24 10:54:36 CDT 2002


On Wed, 24 Jul 2002, Markham, Richard wrote:

> has anyone created a script to find the newest file created
> within a large directory.  struggling with cutting date info
> and need some assistance.

Newest file created?  You can't do that without extra information.  File
creation time is not saved in most Unix filesystems.  I believe that it
may have been in V7 but am not positive.

If you want the file most recently modified (which may also be the newest
file created) then look at the "-t" option to ls.  "ls -t |head -1" will
probably do what you want.

-James



More information about the SunHELP mailing list