jump to navigation

Converting Linux files to Windows format : unix2dos – todos December 29, 2010

Posted by Tournas Dimitrios in Linux.

If you want to share a text file you created on a Linux system with someone on a system running Windows or Mac OS-X , you need to convert the file before the person on the other system can read it easely . The ” todos ” ( part of the tofrodos package) or ” unix2dos ” (part of the unix2dos package) utility converts a Linux text file so it can be read on a Windows of Mac OS-X system .

Usually these packages are installed by default on a CentOs 5.x box , but in case …. , just use the yum installer :   yum install unix2dos .

Give the following command to convert a file name testfile.txt (created with your favorite text editor) to a DOS-format file :

todo testfile.txt or  unix2dos testfile.txt

You can now email the file as an attachment to someone on a Windows or Mac system .Without any options , todos overwrites the original file . Use the ” -b ”  (backup) option to cause ” todos ” to make a copy of the file with a ” .bak ” filename extension before modifying it . Alternatively use the “ -n ” (new) option to cause ” unix2dos ” to write the modified file to a new file as specified by a second argument  :  ” unix2dos  oldfile  newfile ”  .

You can use the ” fromdos ” (part of the tofrodos package ) or  ” dos2unix ” (part of the dos2unix package ) utility to convert Windows or Mas files so they can be read on a Linux system .

See the ” todos ” and ” fromdos ” or ” unix2dos ” and ” dos2unix ” man pages for more information .

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

cat  textfile | tr  -d  ‘\r’  > newtextfile.txt



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s