Created
July 19, 2011 14:27
-
-
Save morygonzalez/1092544 to your computer and use it in GitHub Desktop.
シバンを直すやつ
This file contains 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 | |
#-*- coding: utf-8 -*- | |
require "fileutils" | |
# dir = File::dirname(__FILE__) + '/bin' | |
dir = "/usr/local/rvm/gems/ruby-1.9.2-p290/bin" | |
files = Dir::entries(dir) | |
files.each do |f| | |
unless f =~ /^\.+$/ | |
FileUtils.mv("#{dir}/#{f}", "#{dir}/#{f}_backup") | |
target = File::open("#{dir}/#{f}", "w+") | |
result = [] | |
File.open("#{dir}/#{f}_backup").each do |line| | |
if line =~ /^(.+p?)(?:1\d{2})(.+?\n)$/ | |
line = $1 + "290" + $2 | |
end | |
result << line | |
end | |
target.write(result.join("")) | |
target.close | |
FileUtils.chmod(0755, target) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment