Skip to content

Instantly share code, notes, and snippets.

@morygonzalez
Created July 19, 2011 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morygonzalez/1092544 to your computer and use it in GitHub Desktop.
Save morygonzalez/1092544 to your computer and use it in GitHub Desktop.
シバンを直すやつ
#!/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