KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to test the contents of a file that is generated from code. The problem is that the full name of the file is based on a timestamp abc123_#{d.strftime('%Y%m%d%I%M%S')}.log How could I use File to find this file and read it? I tried doing File.exists?() with a regular expression as the parameter but that didn't work. I found this in another question on stackoverflow: File.basename(file_path).match(/_.*(css|scss|sass)/) How would I be able to use that in my case where the file is located in my public folder? ANSWER So the two answers below both work and I used a combination of them. Dir['public/*.log'].select { |f| f =~ /purge_cc_website/} The * acts as a wildcard that is sort of a regular expression in itself. After that you filter the array using an actual regex.
Tags (comma-separated)
Save Edits
Cancel