01 August, 2007

HowTo convert Windows or DOS text to Linux

If you write text file in Windows, it won't be displayed correctly in Linux, because Windows' editors add carriage return symbol (\^) to the end of each line.
I wrote very simple (but useful) script to migrate text files from Windows to Linux.
Here it is:


dos2linux.sh

#!/bin/bash

cat $1 | tr -d '\r' >$1.fixed


Command "./dos2linux.sh text.txt" reads file "text.txt" and writes fixed file to "text.txt.fixed".

It works on Linux/Unix platforms or under Cygwin environment.

No comments: