Created
August 13, 2009 17:37
-
-
Save jdunphy/167331 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
find = ARGV[0] | |
replace = ARGV[1] | |
unless find && replace | |
puts "You must provide two arguments, find-and-replace <find> <replace>" | |
exit | |
end | |
list = `ack-grep #{find}` | |
list.split("\n").each do |l| | |
filename = l.split(':').first | |
f = File.new(filename).read | |
f.gsub!(/#{find}/, replace) | |
File.open(filename, 'w') do |io| | |
io << f | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment