dos2unix
dos2unix converts text file line endings between DOS (CRLF), Unix (LF), and Mac (CR) formats. It includes utilities like unix2dos, mac2unix, and unix2mac for bidirectional conversion.
Description
This package contains utilities dos2unix, unix2dos, mac2unix, and unix2mac to convert the line endings of text files between UNIX (LF), DOS (CRLF), and Mac (CR) formats. Text files under Windows and DOS typically have two ASCII characters at the end of each line: CR (carriage return) followed by LF (line feed). Older Macs used just CR, while UNIX uses just LF. While most modern editors can read all these formats, there may still be a need to convert files between them.
This is the classic utility developed in 1989. It is useful in scenarios where file compatibility issues arise due to differing line ending conventions across operating systems. The tools support in-place conversion or new file output using the -n option.
How It Works
The tools convert line endings by replacing CRLF (DOS) with LF (Unix), CR (Mac) with LF (Unix), or vice versa. They handle character set conversions like DOS to ISO-8859-1 with specific code pages (e.g., -1252 for Windows, -437 for US DOS). Options allow keeping or removing Byte Order Marks and controlling file ownership changes.
Installation
sudo apt install dos2unixFlags
Examples
unix2dos -n unix.txt dos.txtunix2mac -n unix.txt mac.txtdos2unix -n dos.txt unix2.txtmac2unix -n mac.txt unix3.txtdos2unix -hmac2unix -hunix2dos -hunix2mac -h