On Nov 12, 2007 5:34 PM, Saleem Ansari <[EMAIL PROTECTED]> 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?
> >
>
> 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' '
>
>

Yet again, here is a Ruby one liner:

ruby -e 'puts Dir["./**/*"].delete_if { |f| File.directory?(f) }.sort_by {
|f| File.mtime(f) } [ -1 ]'

Also that it works recursively.

-- 
o1p2e3n4g5l6
http://saleem.a.ansari.googlepages.com/
http://www.jmilug.org/
http://www.csijmi.com/
Linux User #414799 (http://counter.li.org/)
_______________________________________________
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