Created
June 30, 2017 06:13
-
-
Save metzenseifner/0474aca730cb19ec84c16df7c2505fdc to your computer and use it in GitHub Desktop.
Ruby Get Line Endings
This file contains 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
#!/usr/bin/env ruby | |
ARGF.each do |line| | |
if $. == 1 | |
if line =~ /\r\n$/ | |
puts "CRLF" | |
elsif line =~/\n$/ | |
puts "LF" | |
elsif line =~ /\r$/ | |
puts "CR" | |
else | |
puts "Line endings not detected." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment