How to convert line breaks in a text file between the Windows and Unix/Linux formats?
You're probably looking for dos2unix
, unix2dos
, todos
or fromdos
depending on your distribution. Ubuntu/Debian package todos
/fromdos
as part of the tofrodos package from memory.
One option is to use unix2dos
(and dos2unix
for going back) on the command line.
Another is to use a text editor:
For vi: :set ff=dos to set the line endings to be dos line endings.
For emacs: C-x [ENTER] f dos [ENTER]
For your favourite GUI based editor (eg. jedit) I recommend checking the manual or Google.
Lastly if you don't want to deal with a text editor and just do it using more common utilities and such (or don't have unix2dos installed):
tr -d '\r' < infile > outfile
to go from Windows -> Unixawk 'sub("$", "\r")' unixfile.txt > winfile.txt
to go from Unix -> Windows as tr
can not go from Unix to Windows.