------------------------------------------------------------------------ Problem: Convert DOS to Unix ------------------------------------------------------------------------ Apparently each line of a DOS file ends with \r\n whereas lines in Unix files end with \n. [If you wish to create a "DOS" file in a UNIX system then go into vi and "$; a; cntrl V; CR (return)" (here ";" simply indicate a new command) Say you have two files: GenericDOS and OrdinaryUnix (both containing a single line "hello kitty"). There are two ways to determine the type of file $ file GenericDOS GenericDOS: ASCII text, with CRLF, LF line terminators $ file OrdinaryUnix OrdinaryUNIX: ASCII text $ cat -e GenericDOS hello kitty^M$ $ cat -e OrdinaryUNIX hello kitty$ Now you wish to convert from DOS to Unix. There are several solutions $ tr -d '\015' Unix-file $ tr -d '\r' < DOS-file > Unix-file $ sed 's/\r$//' DOS-file > Unix-file $ perl -pi -e 's/\r\n/\n/g' DOS-File > Unix-File $ sed 's/^M$//' DOS-file > Unix-file Here "^M" is obtained by "cntrl-V followed by cntrl-M" In "vi" use thsi command :1,$s/^M// OR :%s/^M// ps. I was not aware that "%=1,$" in vi