Converting different text formats

Line endings

Sometimes you'll have to transfer plain text files from Linux to other systems like Mac or Windows. For this you'll have to deal with different combinations of CR (carriage return) and LF (line feed) for line endings:

System Line ending
UNIX/Linux CR
DOS/Windows CR LF
Mac LF

You may use the commands fromdos or todos to change the line ending format different formats. This can also be done by some text editors like vi or with commands like tr, sed, or similar.

Character encoding

The command iconv allows modification of the text encoding, e.g. from ISO 8859-1 to UTF-8 with iconv -f latin1 -t utf8 file_lat1.txt > file_utf8.txt.

For more information please read the man page or take a look at this article (in German language).

-- StefanHaller - 06 May 2015
Topic revision: r3 - 2015-05-06, StefanHaller