Explore

Loading

Friday, February 10, 2012

Converting Text Files between DOS and Linux

In all versions of DOS (and all subsequent versions of Microsoft Windows), text files are normally written
with both a linefeed character and a newline, both "invisible" control characters, to signify the end of each
line. In Linux and other unices, text files have only the newline character.
In either of these operating systems, text files that originated from the other may display irregularly−−in DOS
and Windows, the lines of a Linux text file may appear to run together; in Linux, a DOS or Windows text file
may have `^M' newline characters at the end of each line.
To convert a text file from DOS to Linux, removing the `^M' newline characters in the file, use
`fromdos'. It converts the file you give as an argument, removing the newline characters from the ends of
all its lines.
To convert a text file from Linux to the convention used by DOS and Windows, use todos. It adds newline
characters to the ends of all lines in the file you give as an argument.
· To remove the newline characters from the text file `autoexec.bat', type:
$ fromdos autoexec.bat RET
· To add newline characters to all of the text files with a `.tex' extension in the current directory,
type:
$ todos *.tex RET
NOTE: Both commands directly write to the files you specify. To make a backup of the original file, use the
`−b' option; before the conversion, this writes a copy of each specified file with a `.bak' file name
extension.
The Linux Cookbook: Tips and Techniques for Everyday Use:
27.

No comments:

Post a Comment