Created
February 3, 2015 08:52
-
-
Save arbaaz/5511fe9169766ee6cb28 to your computer and use it in GitHub Desktop.
remove last new line from all the files in the given folder
This file contains hidden or 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
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