Skip to content

Instantly share code, notes, and snippets.

@arbaaz
Created February 3, 2015 08:52
Show Gist options
  • Save arbaaz/5511fe9169766ee6cb28 to your computer and use it in GitHub Desktop.
Save arbaaz/5511fe9169766ee6cb28 to your computer and use it in GitHub Desktop.
remove last new line from all the files in the given folder
class Rboo < Thor
desc "remove_last_line dir", "remove last line from the all the files in the directory"
def remove_last_line(dir)
puts "You supplied the dir: #{dir}"
files = Dir["#{dir}/**/*.js"]
files.each do |filename|
puts filename
content = File.open(filename, "rb") { |io| io.read }
File.open(filename, "wb") { |io|
io.print content.chomp
# io.print "yourstuff" # Your Stuff Goes Here
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment