From: Phrogz Date: 2007-10-02T22:50:08+09:00 Subject: Re: finding files with regular expressions On Oct 2, 6:17 am, Remco Hh wrote: > I want to search in a directory for files, matching a certain regular > expression. The script should not return true or false, but should give > me a list (array) of filenames which are found. Sorry, I just re-read your request and saw your desire for an array of filenames. How about this: Slim2:/usr/local/bin phrogz$ irb irb(main):001:0> Dir[ '*' ] => ["erb", "fastri-server", "findfile", "fri", "gem", "gem_mirror", "gem_server", "gemlock", "gemri", "gemwhich", "gpgen", "index_gem_repository.rb", "irb", "lua", "luac", "mate", "mongrel_rails", "p4", "p4d", "qri", "rails", "rake", "rdoc", "rdoc- osa", "ri", "ri-emacs", "rot13", "ruby", "sql", "sqlite3", "svn", "svnadmin", "svndumpfilter", "svnlook", "svnserve", "svnsync", "svnversion", "swig", "testrb", "update_rubygems"] irb(main):002:0> Dir[ '*' ].grep /\d$/ => ["p4", "rot13", "sqlite3"] You could use Dir.chdir to pick a working directory if you like.