From: Reid Thompson Date: 2006-08-23T07:59:30+09:00 Subject: Re: How to search Ruby files in Windows Chris Gehlker wrote: > Sometimes you want to find some particular code snippet and all you > know is that it is in some file in a given directory. For example, if > you are reading the Pickaxe book and you want to actually run some > example code, all you know a priori is that it is somewhere in > ex0001.rb through ex1608.rb. I use a Mac and the wonderful Spotlight > Ruby Importer available at: > > makes it trivial to find a file containing any given code snippet. I > have a friend who uses Windows and she doesn't know how to achieve the > same functionality. I've tried running RDoc on the directory > containing the Pickaxe code but it quits because it only works on file > that actually compile. > > So all this is simply to ask: What is the Windows equivalent to the > Spotlight Ruby Importer. > > -- > A young idea is a beautiful and a fragile thing. Attack people, not > ideas. > > I use cygwin (www.cygwin.com) and something like: ( mod to your liking, or make different versions for different needs) cyberhome: /home/rthompso/bin> $ cat greprb if [ $# = 1 ] then dir=. echo "dir is $dir" else if [ $# = 2 ] then dir=$2 echo "dir is $dir" else echo "Usage: 'basename $0' pattern [path]" echo "don't forget to quote patterns with spaces" echo "\n" exit 1 fi fi find $dir -type f -name \*.rb -exec grep -l "$1" {} \; -exec grep -n "$1" {} \; -exec echo " " \; ============================================================================== Example output ( filepath and line of occurance ): $ greprb require . dir is . ./.vim/plugin/snippetMagic/convert.rb 3:require 'rexml/document' 4:require 'rexml/streamlistener' 5:require 'yaml' 7:require 'snippet_set' ./.vim/plugin/snippetMagic/snippets/php.rb 11: - require_once(..) (req1) 12: - "require_once( '${1:file}' );$0" 69: - require(..) (req) 70: - "require( '${1:file}' );$0" ./.vim/plugin/snippetMagic/snippets/propel.rb 16: - " [:milestones_calendar]