Created
June 8, 2012 01:31
Revisions
-
quwubin created this gist
Jun 8, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/usr/bin/env ruby # # Wubin Qu <[email protected]> # if ARGV.size != 1 $stderr.puts " Remove blank lines and leading ^M characters Usage: #{$0} file_name Author: Wubin Qu <[email protected]> " exit end File.open(ARGV[0]).each_line do |line| # Remove ^M when copy files from Windows line.gsub!(/\r\n?/, "\n") # Remove blank line line.sub!(/^\n/, "") next if line.size == 0 $stdout.puts line end