You need to convert DOS formatted text files to the Linux format. In DOS, each line ends with a pair of characters—the return and the newline. In Linux, each line ends with a single newline. So how can you delete that extra DOS character?
Use the -d
option on
tr to delete the character(s) in the supplied list. For example,
to delete all DOS carriage returns (
)
, use the command:
$ tr -d ' ' <file.dos >file.txt
The tr utility has a few special escape sequences that it recognizes, among
them
for carriage return and
for newline. The other special
backslash sequences are listed in Table 8-4.
Table 8-4. The special escape sequences of the tr utility
Sequence | Meaning |
---|---|
| Character with octal value ooo (1-3 octal digits) |
\ | A backslash character (i.e., escapes the backslash itself) |
| “audible” bell, the ASCII BEL character (since “b” was taken for backspace) |
| Backspace |
| Form feed |
| Newline |
| Return |
| Tab (sometimes called a “horizontal” tab) |
| Vertical tab |
18.217.6.114