On Mon, 2007-11-12 at 17:34 +0530, Saleem Ansari wrote:
> On Nov 12, 2007 5:13 PM, ankIT WALiA <[EMAIL PROTECTED]> wrote:
> 
> > Can anyone tell me, how to get latest created file from a folder to be
> > used in shell script?

Well, you can't get the time of creation of a file, as that is
not stored. You can get various other times, such as the time
of modification, time of access (unless this has been turned off
at the filesystem level), and time of modification of file status.

> I believe this will work, but only in current directory ( not recursively )
> 
> ls -l | grep -v '^total' | tr -s " " ' ' | sort -t ' ' -k 6,7 | tail -1 |
> cut -f 8 -d' '

Eek, try,
 ls -lr | tail -1
for time of last access. See "ls -t", and "ls -c" for other times.

Regards,
Gora



_______________________________________________
ilugd mailinglist -- ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd
Next Event: http://freed.in - February 22/23, 2008
Archives at: http://news.gmane.org/gmane.user-groups.linux.delhi 
http://www.mail-archive.com/ilugd@lists.linux-delhi.org/

Reply via email to