Using sed to remove control-M from a series of files

Posted on 1997-11-12
Last Modified: 2013-12-26
I program in DOS and LINUX and often transfer files back and forth.  When I take a file from DOS to LINUX, control-M characters are added at the end of each line.  While these can be removed in textedit one by one, I have a number of files and want to automate it.  I would guess that sed could remove the character from a group of files, but I have no idea how to do it.
Question by:wiggin
LVL 84

Expert Comment

ID: 1295597
tr -d '\015'

Accepted Solution

feenix earned 50 total points
ID: 1295598
You can use this in a script:

sed s/^V^M// < file.dos > file.unix

LVL 84

Expert Comment

ID: 1295599
stty lnext ^V
LVL 51

Expert Comment

ID: 1295600
Linux has: duconv      :-))
You also may use: mcopy -t

Expert Comment

ID: 1295601
There is a utility on SunOS machines named "dos2unix"

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Question regarding Copy/Paste 16 96
windows 10 how make picture as desktop background 2 65
viewing source code from eclipse 13 110
maven archtype selection in eclipse 1 57
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question