O'Reilly logo

Wicked Cool Ruby Scripts by Steve Pugh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Ruby Grep

Ruby Grep

rubyGrep.rb

Imagine this scenario: You have hundreds of files in multiple directories stored on your hard drive—all of which are important and contain information related to a research project. As you're consolidating your final report, you remember reading a figure from one of the papers, but you're not sure which paper, much less which folder, it is in. What to do? Read through the files again? Yeah, right! The first thing to do is not worry! The second thing to do is get a copy of this script and run it. This script will allow you to automatically open files and read the contents, pinpointing the information you need with lightning speed.

The Code

 require 'English'
 unless ARGV[0] puts "\nYou need to include a value to search ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required