Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-13-2008, 11:45 PM   #1
Registered: Mar 2008
Posts: 147

Rep: Reputation: 15
Replace Ctrl-M (^M) characters with spaces....

I have a print file which is having so many ^M (Ctrl-M) characters. How can I replace or delete these using vi editor? or any other solution (sed?)
Old 04-13-2008, 11:59 PM   #2
LQ Newbie
Registered: Apr 2008
Location: Atlanta, GA
Distribution: [linux] Ubuntu, [bsd] FreeBSD, NetBSD
Posts: 21

Rep: Reputation: 15
Originally Posted by visitnag View Post
I have a print file which is having so many ^M (Ctrl-M) characters. How can I replace or delete these using vi editor? or any other solution (sed?)

where you see ctrl-v i mean press ctrl-v, and where you see ctrl-m, i mean press ctrl-m.
Old 04-14-2008, 01:19 AM   #3
Wim Sturkenboom
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
There are commands fromdos and dos2unix to premanently change the file.
Else sed would be the tool to use

See also

vi is not really the right tool to use for this purpose.
Old 04-16-2008, 10:05 AM   #4
Registered: Mar 2008
Posts: 147

Original Poster
Rep: Reputation: 15
When i press Ctrl-M the cursor is going to somewhere else. But strangely i can replace Tabs with anything



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
script to replace spaces with - lleb Linux - Newbie 16 01-04-2008 05:15 PM
Cannot replace spaces w/ underscores clem_c_rock Linux - Newbie 7 09-27-2007 02:17 PM
How to modify the names of files and replace characters with other characters or symb peter88 Linux - General 2 12-10-2006 04:05 AM
How to replace spaces in filenames with underscores rosslaird Linux - Software 4 02-22-2005 02:08 AM
Help! Null Characters to spaces FoxyNewbie Programming 7 05-27-2004 01:10 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration