LinuxReviws.org --get your your Linux knowledge
> Linux Reviews > Tips and Tricks >

Converting text files between Windows and UNIX

Converting text files between Windows format to UNIX format and vice versa

The way textfiles are formatted differs between Windows and Unix. If you open a textfile made in notepad under unix you will find that it has ^M where there should be a new line.

Convert a text file from Windows/dos to unix:

  tr -d '\015' < win-format.txt > unix-format.txt

Convert a text file from unix to Windows/dos:

  sed -e 's/$/\r/' unix-format.txt > win-format.txt

Copyright (c) 2000-2004 Øyvind Sæther. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled ["GNU Free Documentation License" http://www.gnu.org/licenses/fdl.html].


Meet new people