Created
July 29, 2014 14:36
-
-
Save audy/71091381755fba5bd4f0 to your computer and use it in GitHub Desktop.
find replace strings in a text file given a CSV of: target,replacement
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 | |
| require 'csv' | |
| translation = CSV.read(ARGV[0]) | |
| translation.map! { |x| [/#{x[0]}/, x[1]] } | |
| d = File.read('/dev/stdin') | |
| translation.each do |target, replacement| | |
| d.gsub! target, replacement | |
| end | |
| print d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment