<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Tech-Recipes - Latest Comments in Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><language>en</language><lastBuildDate>Thu, 29 Oct 2009 01:24:27 -0000</lastBuildDate><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-21243086</link><description>You Sir are a genius.  I award you five internets!</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Brett</dc:creator><pubDate>Thu, 29 Oct 2009 01:24:27 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-20735223</link><description>Just curious, :%s/\r//g works but :%s/\r\n/\n/g does not, why is that?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">mhannesy</dc:creator><pubDate>Wed, 21 Oct 2009 16:06:06 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-17956723</link><description>Thank you, original post did not work for me, but this did.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ucsbliu</dc:creator><pubDate>Thu, 01 Oct 2009 16:24:19 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-17928659</link><description>Nice, thank you!</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">twitter-14337097</dc:creator><pubDate>Thu, 01 Oct 2009 09:36:17 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-15701304</link><description>hi,&lt;br&gt;     grt man. it worked for me. keep up the good work.&lt;br&gt;&lt;br&gt;br</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">awais</dc:creator><pubDate>Tue, 01 Sep 2009 07:25:54 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-15582158</link><description>Thanks! :D</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">SnowLeopard</dc:creator><pubDate>Sat, 29 Aug 2009 21:19:42 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-13186859</link><description>Thank you very much...for me saved lot of time.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">raod</dc:creator><pubDate>Wed, 22 Jul 2009 22:51:11 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-12243169</link><description>I am trying ti get the diff of a file into a temp.txt file.&lt;br&gt;When I do :%s/^M//g in my file, it says "Pattern not Found: ^M".&lt;br&gt;But when I see the temp.txt file for the diff it shows ^M on all the lines.&lt;br&gt;Help me out for this, I dont want ^M in temp.txt file</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Vishal</dc:creator><pubDate>Tue, 07 Jul 2009 03:12:48 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-12188908</link><description>Lovely! I completely forgot about dos2unix and sincerely I like to use vim better if I can :)</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ciprian</dc:creator><pubDate>Mon, 06 Jul 2009 02:32:42 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-12187254</link><description>Great dude .. this works</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">SOM</dc:creator><pubDate>Mon, 06 Jul 2009 00:19:45 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-10334718</link><description>thanks it  works well</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">S</dc:creator><pubDate>Sun, 31 May 2009 23:56:53 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-10324469</link><description>Excellent</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">sam</dc:creator><pubDate>Sun, 31 May 2009 16:20:50 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-9018531</link><description>You are a genius&lt;br&gt;&lt;a href="mailto:roy@roy.com" rel="nofollow"&gt;roy@roy.com&lt;/a&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">roy</dc:creator><pubDate>Tue, 05 May 2009 13:29:01 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-9008646</link><description>use $ to replace only at the end&lt;br&gt;:%s@^M$@@g</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">xx</dc:creator><pubDate>Tue, 05 May 2009 06:14:22 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-8804192</link><description>this works ! thanks.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">a</dc:creator><pubDate>Wed, 29 Apr 2009 04:52:28 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-8769907</link><description>:%s/\r/\r/g</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ashish</dc:creator><pubDate>Tue, 28 Apr 2009 07:14:49 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-6565509</link><description>another way to get rid of those ^M's&lt;br&gt;:%s/\r//g&lt;br&gt;btw other systems then *nix are treating newlines differently :P</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">3pe</dc:creator><pubDate>Tue, 24 Feb 2009 05:59:31 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-6202076</link><description>great info.. thanks</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Neo</dc:creator><pubDate>Thu, 12 Feb 2009 02:42:00 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-5116309</link><description>thank you for the nice tips. I have plenty of ctrl+M symbols in the dump txt files from dol.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">thanks</dc:creator><pubDate>Wed, 14 Jan 2009 13:21:49 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-4621196</link><description>Thanks it is working fine</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reetesh</dc:creator><pubDate>Wed, 24 Dec 2008 21:52:47 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-4324664</link><description>this solution is not working for ubuntu..:(</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">soma</dc:creator><pubDate>Thu, 11 Dec 2008 02:25:54 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-4081328</link><description>yes the ":%s/^ v ^M//g" is working... thank you very much...</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">pradeep</dc:creator><pubDate>Mon, 01 Dec 2008 06:37:18 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-3582831</link><description>Try perl -pi -e'tr/\015//d' &amp;lt;filename&amp;gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Yo Whirrd up</dc:creator><pubDate>Thu, 06 Nov 2008 23:48:13 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-3575636</link><description>type the following command in vi&lt;br&gt;&lt;br&gt;:%s/.$//</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Maxlen</dc:creator><pubDate>Thu, 06 Nov 2008 16:11:36 -0000</pubDate></item><item><title>Re: Remove ^M characters at end of lines in vi | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/#comment-3270126</link><description>You could try using sed, the stream editor - it works on similar principles to vi's replace tool, but you can pipe into and out of it.&lt;br&gt;&lt;br&gt;So, to change one file:&lt;br&gt;cat fileName | sed s/&amp;lt;ctrl-v&amp;gt;&amp;lt;ctrl-m&amp;gt;//g &amp;gt;tmp &amp;&amp; mv tmp fileName&lt;br&gt;&lt;br&gt;Do NOT try to read from and write to the same file in one pipe, or you'll blank the file&lt;br&gt;&lt;br&gt;To change all files in a directory with the .sql ending, run the following script whilst inside that directory:&lt;br&gt;#/bin/ksh&lt;br&gt;for fileName in $(ls *.sql); do&lt;br&gt;  cat $fileName | sed s/^M//g &amp;gt;tmp &amp;&amp; mv tmp $fileName&lt;br&gt;done&lt;br&gt;&lt;br&gt;(bear in mind to enter ^M you need to enter &amp;lt;ctrl-v&amp;gt;&amp;lt;ctrl-m&amp;gt; as above.&lt;br&gt;&lt;br&gt;Hope that helps people&lt;br&gt;-phobiandarkmoon</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Phobian</dc:creator><pubDate>Fri, 24 Oct 2008 04:57:15 -0000</pubDate></item></channel></rss>