Name

Find — Directory tree traversal module

Synopsis

The Find module provides a depth-first directory traversal.

Required Library

require ‘etc’

Example

require 'find'

# prints all files with ".c" extension.
Find.find(".") {|f|
  puts f if /\.c$/ =~ f
}

Module Functions

find(path...) {|f| ...}

Traverses directory tree giving each filename to the block

prune

Terminates traversal down from the current directory

Get Ruby in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.