windows file to unix :end line chararcter

hi ,

  When i ftp  a text file from Windows to unix enviornment  and open the file in  " vi editor" the  end line charcrter of the windows file is seen as "cntrl\+M" charcter in  the Unix enviornment.

Is there any command in unix , so that i dont see this "cntrl+M"
chararcter in the Unix vi editor.

Thanx,

"dos2unix"
and
"unix2dos" can be used to convert the files from dos to unix and vice versa using unix2dos

You can get it from web for free
Cheers
JK

Or even more simply, you transfer your text files in FTP ASCII mode.

hi,
in the Vi editor it still shows me the cntrl+M characters for the end- line ,
after using the dos2unix command ....
Is there any command by which the cntrl+M in vi editor can be made invisible........

Well there is one utility called flip (option -u to remove the ^M)

flip -u filename

that will remove the ^M, but I don' t know whether this is supported by all.

As for the dos2unix is concerned it will just put the output to the console, you can redirect it to some junk file or the same file.

dos2unix filename > junk.txt
mv junk.txt filename

Cheers
JK

hi jaya,
My unix is solaris 5.8 , it doesnt support " flip " caoomand i guess . But its fine when i trasfer the file in
"ASCII" mode i get the file w/o cntrl+M characters ...
So the problem is solved...
Cheers,
Dharmesh

Hi Dharmesh,

Still if you will ever find a file that contains the CTRL + m characters there is a very easy way to get rid of them. They have been mention many times here on the forums.

The way to do this is to open the file using vi. Stay in Escape mode and type the following :

:1,$s/<CTRL>+v <CTRL>+m//g

<ctrl>+v says that the next character is a special character. This will be substituted with nothing. i.o.w. removed :slight_smile:
:1,$ just says from line number 1 until the end.

Regs David

hi david,

thats perfect ...... i tried it is fine
thank u so much.

Hi

I seem to have a problem not mentioned here. The version of (x)emacs that I use most often doesn't seem to insert any line breaks at each ^M, so when I use dos2unix I lose the line breaks altogether in all text editors (e.g. newer versions of (x)emacs and in Windows). Does anyone have any ideas how to get around this ?

Cheers,
James

I don't use dos2unix at all. Just ftp the file to unix and then ed filename. In the status line you will see an indicator that this is a DOS file (i.e. has CRLF as end of line instead of UNIX's LF). If necessary, you can then use 'C-x RET f big5-unix' to change the coding to UNIX.