From: Suraj Kurapati Date: 2010-08-24T05:39:43+09:00 Subject: Re: directory listing without . and .. Suraj Kurapati wrote: > Robert Klemme wrote: >> dirs = Dir[File.join(path, '*')].select {|x| File.directory? x} > > Use the directory matching power of file globbing patterns: > > dirs = Dir["#{path}/*/"] > > Here, the '/' suffix makes the pattern match directories only! If you also want to match dot-directories, use more glob power: dirs = Dir["#{path}/{*,.[^.]*}/"] This will match both normal directories (*/) and dot directories (.[^.]*/). But it will fail if you have a directory named '..foo' or '........bar', for example. Cheers. -- Posted via http://www.ruby-forum.com/.