Trying to do this with command line or with ruby, but I have a number of folders which their names correspond to a date (they are db dumps), I want to find the latest folder and do something with it.
Example: /dumps
has folders: /dumps/2015-08-09
, /dumps/2015-08-11
, /dumps/2015-08-20
How can I do so in command line or perhaps ruby?
Thanks!
由于子文件夹具有明智的名称:
last_folder = Dir.glob("/dumps/*").sort.last
use ls
ls -lrt dumps/*
should work
and than you can use tail -n1
to get the last line
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.