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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 92
repeatSeparator  java  challenge 13 57
Turn a spreadsheet into a vba executable. 2 86
move a line in eclipse 3 102
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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.

772 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