Skip to content

Instantly share code, notes, and snippets.

@davidbody
Created February 10, 2009 20:07
Show Gist options
  • Save davidbody/61565 to your computer and use it in GitHub Desktop.
Save davidbody/61565 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Finds all files in app directory that have CRLF line endings
# and converts them to LF line endings by removing all of the CR (\r) characters.
files = %x{find app -exec file {} \\; | grep CRLF}.map{|s| s.gsub(/:.*$/, '').strip}
files.each do |f|
puts "Processing #{f}"
system "tr -d '\\r' < #{f} > #{f}.new"
system "mv #{f}.new #{f}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment