-
Website
http://www.tech-recipes.com/ -
Original page
http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
davak
83 comments · 1 points
-
Web Design
3 comments · 1 points
-
danishbacker
9 comments · 1 points
-
flexinfo
11 comments · 1 points
-
Tonychelle
4 comments · 1 points
-
-
Popular Threads
-
Facebook: How To Get Only Status Updates on Your FB Home Page
1 week ago · 4 comments
-
Firefox: Enable Case Sensitive Searches When Using Find (Ctrl+F)
5 days ago · 1 comment
-
Firefox 3.6: Enable Visual Previews When Using Ctrl+Tab (Windows Only)
6 days ago · 1 comment
-
Windows 7: How To Disable Live Preview for Taskbar Thumbnails
2 weeks ago · 2 comments
-
Gmail: How to block a sender from your inbox
3 weeks ago · 3 comments
-
Facebook: How To Get Only Status Updates on Your FB Home Page
cat foo | col -b > foo2
:%s/<control-v><control-m>//g
^M is the result of a control V, control M at the end of the line. if you actually hit control-v then control-m, "^M" will appear and will get rid of the character at the end of the line. hope this helps someone!!!
roy@roy.com
col -bx <dosfile> newfiledoes the biz. too :)
Right On!
THere is lot of non-continous blank lines in my shell. I want to find the blank line and I want to remove it. What is the command for that?
Sasi, India
:%s/^$//gwill find blank lines and make them disapear.
While I can do each one individually by :%s/^M//g I would like to know if there is an easy command line execution to serarch for any files containing the errors and correct them.
I tried this for all *.sql files in a given directory, but it didn't work:
for name in `ls *.sql` ; do sed 's/^M//' $name > ${name/.sql/N.sql} ; mv ${name/.sql/N.sql} $name ; done
If anyone has a suggestion or knows a simple script that can be run please let me know.
Thanks
So, to change one file:
cat fileName | sed s/<ctrl-v><ctrl-m>//g >tmp && mv tmp fileName
Do NOT try to read from and write to the same file in one pipe, or you'll blank the file
To change all files in a directory with the .sql ending, run the following script whilst inside that directory:
#/bin/ksh
for fileName in $(ls *.sql); do
cat $fileName | sed s/^M//g >tmp && mv tmp $fileName
done
(bear in mind to enter ^M you need to enter <ctrl-v><ctrl-m> as above.
Hope that helps people
-phobiandarkmoon
:%s/.$//
:%s/\r//g
btw other systems then *nix are treating newlines differently :P
:%s@^M$@@g
When I do :%s/^M//g in my file, it says "Pattern not Found: ^M".
But when I see the temp.txt file for the diff it shows ^M on all the lines.
Help me out for this, I dont want ^M in temp.txt file
grt man. it worked for me. keep up the good work.
br