Skip to content

Instantly share code, notes, and snippets.

@rnakano
Created April 3, 2015 06:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnakano/61ae273b55851639665c to your computer and use it in GitHub Desktop.
Save rnakano/61ae273b55851639665c to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
if ARGV.size != 3
puts "usage: ack-sed <pattern> <replace-string> <dir>"
end
query, replace, dir = ARGV
system("ack #{query} #{dir} | cut -d':' -f1 | uniq | LANG=C xargs sed -i -e 's/#{query}/#{replace}/g'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment