Skip to content

Instantly share code, notes, and snippets.

@cth
Created April 22, 2010 06:48
Show Gist options
  • Save cth/374899 to your computer and use it in GitHub Desktop.
Save cth/374899 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Simple utility to remove trailing space in the end of lines
# Takes as first argument the file to be processed.
lines = []
File.open(ARGV[0]).each do |line|
line.reverse =~ /\s*(.*)/
lines << $1.reverse
end
File.open(ARGV[0],"w") { |file| lines.each { |line| file << line << "\n" } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment