Код: Выделить всё
#!/bin/sh
{
printf 'a\n' # UNIX EOL
printf 'b\r\n' # Windows EOL
printf 'c\r' # Old macOS EOL
printf 'd' # Illegal last text line
} | python -c '
import fileinput
for line in fileinput.input(files=["-"], mode="rU"):
if line.endswith("\n"):
line = line[:-1] # chomp
print(repr(line))
'
Код: Выделить всё
'a'
'b\r'
'c\rd'
Код: Выделить всё
'a'
'b'
'c'
'd'
Подробнее здесь: https://stackoverflow.com/questions/798 ... malization
Мобильная версия