1 <qandaentry id="dos-text">
2 <question><para>What's a DOS format text file?</para></question>
3 <answer><para>It has to do with the characters used to end lines.
5 <para>There are two that may be used:
8 <listitem><para>Line Feed: (LF) Octal:012 Decimal:10 Hex:0A C Style Escape:'\n'
12 <listitem><para>Carriage Return: (CR) Octal:015 Decimal:13 Hex:0D C Style Excape:'\r'
13 Move to the left margin.
18 <para>Unix, DOS, and MacOS each use a different combination to end lines in text files:
21 <listitem><para>Unix: LF only.
22 This is why when a Unix format text file is sent to a printer raw, it prints out
29 <listitem><para>DOS: CRLF both.
30 Which is why if you do "cat -v" on a DOS file you'll see a "^M"
31 (control m is carriage return) at the end of each line. And that
32 is why scripts don't work when written with Microsoft Notepad.
33 The kernel looks for "/bin/sh^M" which doesn't exist. There's a
34 "/bin/sh", but nothing with a "^M" appended.
37 <listitem><para>MacOs: CR only.
38 Printers probably print every line atop the first, and Unix tools
39 think the whole file is one line with "^M" all through it.
44 <para>To change DOS to Unix, use
45 <screen>cp <filename> <filename>.dos &&
46 cat <filename>.dos | tr -d '\r' > <filename>
48 Other conversions will probably require sed or a different use of tr
49 and are left as an exercise for the reader.