Skip to content

Instantly share code, notes, and snippets.

@jdunphy
Created August 13, 2009 17:37
Show Gist options
  • Save jdunphy/167331 to your computer and use it in GitHub Desktop.
Save jdunphy/167331 to your computer and use it in GitHub Desktop.
#!/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