Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Types of line endings

📅 2020-Sep-23 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ newline ⬩ 📚 Archive

A line ending is one or two characters used in text files to indicate the end of a line and thus the beginning of the next line.

$ file windows.c
windows.c: C source, ASCII text, with CRLF line terminators

$ file linux.py
linux.py: Python script, ASCII text executable
$ dos2unix windows.c
$ unix2dos linux.py
$ find . -type f | xargs dos2unix -ic

The CR character in DOS files is rendered as ^M at the shell or in Vim, so looking for that character is another way to find DOS files.

$ find . -type f | xargs dos2unix -ic | xargs dos2unix

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧