14.8. Working with Files, Directories, and Trees
A broad area of everyday scripting is to work with files and directories, including entire subtrees of files. Much of the relevant material has already been covered in Chapter 4, “Internationalization in Ruby,” but we will hit a few high points here.
Because I/O is a fairly system-dependent thing, many tricks will vary from one operating system to another. If you are in doubt, you should resort to experimentation.
14.8.1. A Few Words on Text Filters
Many tools that we use every day (both vendor-supplied and home-grown) are simply text filters; that is, they accept textual input, process or transform it in some way, and output it again. Classic examples of text filters in the UNIX world are sed ...