in reply to Re: Re: ^M gets added to the end of the line while replacing strings
in thread ^M gets added to the end of the line while replacing strings

So maybe it has got something to do with the file being originated in wondows.

Yes, it has everything to do with that.

The dos2unix utility is your friend.

You can fix it with perl too using a command like like:

perl -i.bak -pe 's/\r\n/\n/' file.txt

BTW, vi tries to be smart about whether it displays those ^M characters... which is probably why you didn't see them the first go around.

-sauoq
"My two cents aren't worth a dime.";
  • Comment on Re: Re: Re: ^M gets added to the end of the line while replacing strings
  • Download Code