Command to Convert Line Endings from CR+LF (Windows) to LF (Linux) [Linux, macOS Edition]

Tadashi Shigeoka ·  Thu, March 21, 2019

I’ll introduce how to convert line endings from CR+LF (Windows) to LF (Linux) on Linux and macOS.

Linux

Basic Knowledge of Line Endings

  • Linux line ending: LF
  • Windows line ending: CR+LF

tr Command Usage Example

tr '\\r' '\
' < input.txt > output.txt

That’s all from the Gemba on wanting to batch convert line endings from CR+LF (Windows) to LF (Linux) using commands on Linux and macOS.

Reference Information