我怎样才能得到使用Ruby的目录中最后创建的文件的路径? [英] How can I get the path for the last created file in a directory using Ruby?

查看:106
本文介绍了我怎样才能得到使用Ruby的目录中最后创建的文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这是相当公平的简介:

  Dir.glob(File.join(path,'*。*'))。max {| a,b | File.ctime(a)< => File.ctime(b)} 


How can I get the path for the last created file in a directory using Ruby?

解决方案

I think this is fairly brief:

Dir.glob(File.join(path, '*.*')).max { |a,b| File.ctime(a) <=> File.ctime(b) }

这篇关于我怎样才能得到使用Ruby的目录中最后创建的文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆