Unix2dos Converts Linux and Macintosh Files to Windows Format

If you want to share a text file that you created on a Linux system with someone on a Windows or Macintosh system, you need to convert the file before the person on the other system can read it easily. The unix2dos utility converts a Linux text file so that it can be read on a Windows or Macintosh system. This utility is part of the tofrodos software package; give the command sudo aptitude install tofrodos to install this package. Give the following command to convert a file named memo.txt (created with a text editor) to a DOS-format file:

$ unix2dos memo.txt

Without any options unix2dos overwrites the original file. You can now email the file as an attachment to someone on a Windows or Macintosh system.

dos2unix You can use the dos2unix utility to convert Windows or Macintosh files so they can be read on a Linux system:

$ dos2unix memo.txt

See the unix2dos and dos2unix man pages for more information.

You can also use tr to change a Windows or Macintosh text file into a Linux text file. In the following example, the -d option causes tr to remove RETURNs (represented by \r) as it makes a copy of the file:

The greater than (>) symbol redirects the standard output of tr to the file named memo.txt. For more information refer to "Redirecting Standard Output" on page 228. Converting a file the other way without using unix2dos is not as easy.

Was this article helpful?

0 0

Post a comment