Often I need to translate source code from dos/windows format to UNIX format, MS-DOS and WINDOWS use a <carriage return>-<line feed> combination to represent end of line char while UNIX uses only a <line feed>.
To traslate from a format to the other you can use dos2unix command, if this command is not availble in your system you can use vi to traslate from Dos to Unix.
- Open the file with VI
# vi orig_file.txt
- substitute the <carriage return>-<line feed> combination with only a line feed typing the following command:
:%s/^M//g
to compose the ^M character you need to press CTRL-V -> CTRL-M
- Save the file with the following command
:w converted_file.txt
- Exit from vi
:q
Have a good day!