0

I have a file in Unix in which I am getting carriage return (^M) followed by linefeed.There are many other newline (enter) within the file which are not followed by linefeed.I want to remove this carriage return (^M) followed by linefeed such that other newline which are not followed by linefeed are not affected .Can you please suggest any command for this. Thanks in advance.

user328535
  • 11
  • 1
  • 2
    Would http://stackoverflow.com/questions/800030/remove-carriage-return-in-unix help? Would your question be a duplicate of that one? – VonC Apr 29 '10 at 06:01

1 Answers1

0

Open the file using vi editor, type :%s@$@@g

This will remove the Control-M characters only at the end of every line.

or

use the below perl syntax

perl -e 's/\r//g' -w -p -i

To view the Control-M characters, use vi -b

prasankn
  • 81
  • 1
  • 1
  • 11