I have been googling and am not sure how to approach this. I have a file that I need to match. The date string in the filename varies so I want to match any date. /path/to/file/hist_sar01-31-2013.tar What options do i have for matching the/any date or string. Is there a method for matching? hist_sar*.tar
on 2013-02-15 00:59
on 2013-02-15 01:47
yes! You want to use a regex. May I suggest something like: /hist_sar\d+-\d+-\d+\.tar/
on 2013-02-15 01:53
On Thu, Feb 14, 2013 at 4:59 PM, Sloan Ruby <lists@ruby-forum.com> wrote: > if Dir["/path/to/file/hist_sar*.tar"].empty? # code to run if no files matching pattern exist else # code to run otherwise end You could also make the pattern more specific: http://www.ruby-doc.org/core-1.9.3/Dir.html#method-c-glob Example: Dir["/path/to/file/hist_sar{0,1}[0-9]-[0-3][0-9]-[0-9][0-9][0-9][0-9].tar"]
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.