Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.40 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. if ARGV[0]
  4.     myfile = ARGV[0]
  5. else
  6.     puts "No filename given"
  7.     exit 1
  8. end
  9.  
  10. system("mv \"#{myfile}\" \"#{myfile}.bak\"")
  11. File.open("#{myfile}", "w") do |outfile|
  12.     IO.foreach("#{myfile}.bak") do |line|
  13.         if line =~ /size = \d+/
  14.             outfile.print line.sub(/(\d+)/) {|match| match.to_i/10}
  15.         else
  16.             outfile.print line
  17.         end
  18.     end
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement