[PLUG] BASH Script to find last created file in a directory

Matt Wallace wallacms@cs.purdue.edu
Mon, 12 Feb 2001 18:45:26 -0500 (EST)


Well, the problem here is that UNIX doesn't keep track of file creation
time, only file modification time.  So if the last modified file will do,
then you can do it with one command:

ls -t | head -1

HTH,

Matt

On Mon, 12 Feb 2001, Aaron Lehmann wrote:

> I need to find the last created file in a directory for a script I'm
> writng, and then rename it.  Can I grep for the last created file, and
> make a variable equal to that name?  Is there a better way.  Also, I'd
> really like to have an answer in BASH Scripting language.  I'm sure that
> PERL would do this better (or that some other thing will be), but I
> don't really want to have to modify the rest of thing to fit.
>
> Thanks,
> Aaron Lehmann
> --
> I agree with Matt.
> ____________________________________________________
> The Purdue Linux Users' Group (PLUG) mailing list.
> For account maintenance, go to:
> plug mailing list  -  plug@csociety.purdue.edu
> http://csociety.ecn.purdue.edu/mailman/listinfo/plug
>
>