Converting text files between Windows and UNIX


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