Saturday, April 2, 2011

How to remove CONTROL-M characters in UNIX or Linux

Control-m characters will get appended to a file when a file is transferred from windows to UNIX machine. There are multiple ways it can be removed.

Using vi editor:

Using col command:
cat filename | col -b > newfilename

Using sed command:
sed 's/^M//g' filename > newfilename

Using dos2unix comand:
dos2unix filename newfilename


volcano@volcano-laptop:~/shellscript/ctrl$ cat -v jsk
volcano@volcano-laptop:~/shellscript/ctrl$ cat jsk | col -b >
volcano@volcano-laptop:~/shellscript/ctrl$ cat -v
volcano@volcano-laptop:~/shellscript/ctrl$ sed 's/^M//g' jsk > jsk.new2
volcano@volcano-laptop:~/shellscript/ctrl$ cat -v jsk.new2

Note: Hold the control key and then press v and m to get the control-m character


ujjwal singh said...

Thanks Sujay,

Narasimha Rao said... provides CONTROL-m in hyderabad with best faculties on real time projects. We give the best online trainingamong the CONTROL-m in Hyderabad.
Classroom Training in Hyderabad India

venkatesh reddy said...

using any of the above command(sed,dos2unix,etc) i am not able clear CONTROL-M characters. Please suggest us to solve this issue.

Murali said...

Great job! thanks a million !!
I used the following command from the above and it worked like a champ. I am on AIX 6.1

cat filename | col -b > newfilename

Thanks a lot!!!!

mahasiswa teladan said...

hi...Im student from Informatics engineering nice article,
thanks for sharing :)

rahim said...

Very goo, Thanks :)

James Sa said...

why dos2unix doesn't remove ^M if the dos text file has ^M without line feed?

Seshank satavilli said...

I am not able to remove the ^M characters.

the contents of the file:


How to remove these?

Desired content in the file

Thanks in advance.

Bogon said...

For the inline ^M, you can use this:

$ sed 's/\cM/\n/g' file.txt > newfile.txt

This assumes that your text stream ends with a newline (conventionally \n)

murali krishna said...

Command suggested through vim doesnt work. Instead try this

Sri said...

I have tried Col option which really helped me. Thanks much

joshnson haddin said...

A guarantee of appreciation is oracle training in chennai all together for sharing the key data and its really stunning.informatica training in chennai


good explanation has been given about Linux.This is the best article i have seen
about Linux.thanks for giving good explanation.
oracle fusion procurement online training

Calfre India said...

Oracle fusion financials online training institute we have our branch over all the india. Oracle Fusion Financials Online Training in Hyderabad, Bangalore, Delhi, Chennai, Kolkata, Pune, Mumbai, Ahmedabad, Gurgon, Noida, India, Dubai, UAE, USA, Kuwait, UK, Singapore, Saudi Arabia, Canada, Oracle Fusion financials Online Trainings

Oracle fusion Financials Online Training

Oracle Fusion Financials online Training

Priya Kannan said...

I just see the post i am so happy the post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be subscribing to your feed and I hope you post again soon.
UNIX Training in Chennai

oracle34 said...

thank for sharing use full information for more
Attend free demo classes at igofusion for Oracle Fusion Financials coaching

suresh H said...

Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.
Best AngularJS Training in Chennai
Hadoop Training in Chennai
Big Data Training in Chennai

Sandeep Oracle said...

That is a good tip, especially to those new to the blogs here but very accurate information. Very nice blog post!! Thanks for the posting that is a really neat written blog..........Visit our website known about Fusion SCM Training in Ameerpet Hyderabad.

sravanthi said...

Really very helpful article , Thank you for sharing.

Oracle Fusion Technical Training In Hyderabad

oracle calfre said...

Search for Oracle Training Institute details in our local search engine Calfre.

Unknown said...

Thanks for posting the blog. I felt comfortable while reading the post. Keep posting more blogs.
we are the best CALFRE Search Engine search about all different courses in Al Karama, Dubai Locations. For Example Search a course like Oracle SQL Training Know More Click Here

calfre search said...

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Your write up is a fine example of it.

Oracle Fusion SCM Training in Hyderabad

cal fre said...

Hi, Thanks for sharing a nice information of the blog.
It's really nice blog. For more info please visit.
IOT Training Institutes in Ameerpet

aravind g said...


amilu B said...

I really like your blog. You make it interesting to read and entertaining at the same time. I cant wait to read more from you.

python training in omr

python training in annanagar | python training in chennai

python training in marathahalli | python training in btm layout

python training in rajaji nagar | python training in jayanagar

simbu said...

Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

java training in omr

java training in annanagar | java training in chennai

java training in marathahalli | java training in btm layout

java training in rajaji nagar | java training in jayanagar

Anexas Europe said...

It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.

Digital Marketing Training in Mumbai

Six Sigma Training in Dubai

Six Sigma Abu Dhabi

shalinipriya said...

Excellent blog, I wish to share your post with my folks circle. It’s really helped me a lot, so keep sharing post like this

Data Science Training in Chennai
Data science training in bangalore
Data science online training
Data science training in pune
Data science training in kalyan nagar
selenium training in chennai

Saro said...

Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.

rpa training in Chennai | rpa training in velachery

rpa training in tambaram | rpa training in sholinganallur

rpa training in Chennai | rpa training in pune

rpa online training | rpa training in bangalore

Mouni yoga said...

This looks absolutely perfect. All these tiny details are made with lot of background knowledge. I like it a lot. 
python online training
python training in OMR
python training in tambaram

Deepika Analy said...

Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.

UX Design Training
UX Design Training in Chennai

Amar G said...

UiPath Training in Bangalore by myTectra is one the best UiPath Training. myTectra is the market leader in providing Robotic Process Automation on UiPath
robotic process automation training in bangalore

Anexas Europe said...

Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
Good discussion. Thank you.
Six Sigma Training in Abu Dhabi
Six Sigma Training in Dammam
Six Sigma Training in Riyadh

shethal said...

Thanks for your informative article, Your post helped me to understand the future and career prospects & Keep on updating your blog with such awesome article.
Devops training in sholinganallur
Devops training in velachery

cynthia williams said...

Thanks for sharing tips and tricks admin. It is really helpful, keep up the good work and share more like this.
RPA Training in Chennai
Robotics Process Automation Training in Chennai
RPA courses in Chennai
DevOps Training in Chennai
AWS Training in Chennai
Angularjs Training in Chennai

Sai Elakiyaa said...

Amazing post. It will be very helpful for beginners like me. Thank you very much for this kind of post.Waiting for your next blog.

Selenium training in Chennai
Selenium Courses in Chennai
best ios training in chennai
Digital Marketing Training in Chennai
JAVA J2EE Training Institutes in Chennai
Best PHP training in chennai
PHP Training

Shiva Shakthi said...

The information which you shared is very much intresting. Thanks for sharing the amazing blog.
Web Designing Course in Coimbatore
Web Design Training in Coimbatore
Web Designing Training Institute in Coimbatore
Web Design Training Coimbatore
Best Web Designing Institute in Coimbatore

Vicky Ram said...

Thanks for sharing this information.

Guest posting sites

Aruna Ram said...

Wonderful article!!! It is very useful for improve my skills. This blog makes me to learn new thinks. Thanks for your content.
CCNA Certification in Bangalore
CCNA Training Bangalore
CCNA Training institutes in Bangalore
CCNA Course in Kodambakkam
CCNA Training in Aminjikarai
CCNA Course in Chennai Kodambakkam

Anbarasan14 said...

Your blog is nice. I believe this will surely help the readers who are really in need of this vital piece of information. Thanks for sharing and kindly keep updating.

English Speaking Course in Bangalore
Best Spoken English Classes in Bangalore
Spoken English in Bangalore
Best Spoken English Training Center near me
Spoken English Institute in Chennai
English Coaching Classes in Chennai
Best Spoken English Class in Chennai

dinesh said...

This information is impressive. I am inspired with your post writing style & how continuously you describe this topic. Eagerly waiting for your new blog keep doing more.
Android Training in Bangalore
Android Course in Bangalore
Android Training Institutes in Bangalore
Best Android Training Institute in Bangalore
Android Classes in Bangalore
Aws Training Institutes in Bangalore
Aws Certification Training in Bangalore
Aws Training Center in Bangalore
hadoop institute in bangalore
best institute for bigdata in bangalore
big data coaching in bangalore

sharmi chithra said...

It is very excellent blog and useful article thank you for sharing with us, keep posting.

Primavera Training in Chennai
Primavera Course in Chennai
Primavera Software Training in Chennai
Best Primavera Training in Chennai
Primavera p6 Training in Chennai
Primavera Coaching in Chennai
Primavera Course

nanadhini chandran said...

This blog is more effective and it is very much useful for me.
we need more information please keep update more.
Salesforce Training in Thirumangalam
Salesforce Training courses near me
Salesforce Training in Vadapalani
Salesforce Training in Amjikarai

sharmi chithra said...

Nice post. By reading your blog, I get inspired .. Thank you for posting.

Informatica Training chennai
Informatica Training institutes in Chennai
Best Informatica Training Institute In Chennai
Best Informatica Training center In Chennai
Informatica institutes in Chennai
Informatica courses in Chennai
Informatica course
Informatica MDM Training in Chennai

vishnu said...

Thank you for sharing this valuable information. Keep up the good work.

Best Linux Training Institute in Chennai
Best Linux Training in Chennai
Learn Linux
Linux Training in Adyar
Linux Course in Velachery
Best Linux Training Institute in Tambaram

Sadhana Rathore said...

Thanks for sharing this pretty post, it was good and helpful.
R Training in Chennai
R Training near me
R Programming Training in Chennai
Data Analytics Training
R course
R Training in Velachery

LindaJasmine said...

You are an awesome writer. The way you deliver is exquisite. Pls keep up your work.

Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
Spoken English Class in Chennai
Spoken English in Chennai
Best Spoken English Class in Chennai
English Coaching Classes in Chennai
Best Spoken English Institute in Chennai

Safety Professionals said...

If so how do you stop it, any plugin or anything you can advise? I get so much lately it’s driving me insane, so any assistance is very much appreciated.
safety course in chennai

venu bharath said...

You are an awesome writer. The way you deliver is exquisite. Pls keep up your work.
Spoken English Classes in Chennai
Best Spoken English Classes in Chennai
Spoken English Class in Chennai
Spoken English in Chennai
Best Spoken English Class in Chennai
English Coaching Classes in Chennai
Best Spoken English Institute in Chennai
IELTS coaching in Chennai
IELTS Training in Chennai

LindaJasmine said...

Great Post. Your article is one of a kind. Thanks for sharing.
Ethical Hacking Course in Chennai
Hacking Course in Chennai
Ethical Hacking Training in Chennai
Certified Ethical Hacking Course in Chennai
Ethical Hacking Course
Ethical Hacking Certification
Node JS Training in Chennai
Node JS Course in Chennai

Praylin S said...

Very interesting and informative post! Glad that I came across your post. Thanks for sharing.
Oracle Training in Chennai | Oracle Training institute in chennai | Oracle course in Chennai | Oracle Training | Oracle Certification in Chennai | Best oracle training institute in Chennai | Best oracle training in Chennai | Oracle training center in Chennai | Oracle institute in Chennai | Oracle Training near me

Durai Raj said...

The blog which you are posted is innovative…. thanks for the sharing…
Digital Marketing Training in Chennai
Digital Marketing Classes in Coimbatore
Digital Marketing Institute in Bangalore
Digital Marketing Training Institute in Bangalore

jefrin adams said...

Best post thanks for sharing

Best php training in chennai

Rohil singh said...

I think this is the best article today about the future technology. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic. Artificial Intelligence Training in Bangalore. Keep sharing your information regularly for my future reference.

mahi eswari said...

Thanks for sharing the details!
Cognos training in hyderabad

Bee Yes said...

Amazing Article ! I have bookmarked this article page as i received good information from this. All the best for the upcoming articles. I will be waiting for your new articles. Thank You ! Kindly Visit Us @ Coimbatore Travels | Ooty Travels | Coimbatore Airport Taxi

Shadeep shree said...

Outstanding Blog!!! Thanks for sharing with us...
CCNA Course in Coimbatore
CCNA Training in Coimbatore
CCNA Course in Madurai
CCNA Training in Madurai
Ethical Hacking Course in Bangalore
German Classes in Bangalore
German Classes in Madurai
Hacking Course in Coimbatore
German Classes in Coimbatore

jefrin adams said...

Wow good to read thanks
Best R programming training in chennai

suresh said...

Thanks for your sharing

Data Science Training in Chennai

DevOps Training in Chennai

Hadoop Big Data Training

Python Training in Chennai

luckys said...

indian whatsapp group links

Manisha singh said...

nice blog, I like your good post, thanks for sharing great information.
Linux Training in Gurgaon
Linux Course in Gurgaon
Linux Training institute in Gurgaon

ajay prakash said...

Such an excellent and interesting blog, do post like this more with more information, This was very useful, Thank you.
Aviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
Aviation Courses in Chennai
cabin crew training chennai
Airport Management Training in Chennai
airport ground staff training courses in chennai

karthick said...

Very Clear Explanation. Thank you to share this
Digital Marketing Course in chennai

service care said...

This is the exact information I am been searching for, Thanks for sharing the required infos with the clear update and required points.
oppo service center velachery
oppo service center in vadapalani
oppo service center in porur

service care said...

Thanks for giving great kind of information. So useful and practical for me. Thanks for your excellent blog, nice work keep it up thanks for sharing the knowledge.
oneplus service
oneplus service centres in chennai
oneplus service center velachery

jaya devan said...

Really awesome blog. Your blog is really useful for me
selenium training institute in chennai

service care said...

I think this is a great site to post and I have read most of contents and I found it useful for my Career .Thanks for the useful information. Good work.Keep going.
samsung mobile service chennai
samsung mobile repair
samsung mobile service center near me

tamizh said...

You blog post is just completely quality and informative. Many new facts and information which I have not heard about before. Keep sharing more blog posts.
devops online training

aws online training

data science with python online training

data science online training

rpa online training

priya said...

Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries. I want to say thanks for great sharing.
Microsoft Azure online training
Selenium online training
Java online training
uipath online training
Python online training

Raji said...

Thanks for sharing worthy information. This is really helpful for learning. Keep doing more.
R Training Institute in Chennai | R Programming Training in Chennai

anusha said...

data science training in chennai Data Science Training in Chennai with real time projects. We are Best Data Science Training Institute in Chennai. Our Data Science training courses are taught by Experts.

Rainbow Training Institute said...

Thank you for sharing your awesome and valuable article this is the best blog for the students they can also learn.

Workday HCM Online Training

Rainbow Training Institute said...

Thanks for sharing such a good article having valuable to learn Big Data and Hadoop Training course.

Big Data and Hadoop Training In Hyderabad