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.

1

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.