We help IT Professionals succeed at work.

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

wiggin
wiggin asked
on
Medium Priority
1,573 Views
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.
Comment
Watch Question

ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
tr -d '\015'
Commented:
You can use this in a script:

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
assuming
stty lnext ^V
Linux has: duconv      :-))
You also may use: mcopy -t
jrg

Commented:
There is a utility on SunOS machines named "dos2unix"
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.