remove ^M characters from file using sed

Use tr:

tr -d '^M' < inputfile

(Note that the ^M character can be input using Ctrl+VCtrl+M)


EDIT: As suggested by Glenn Jackman, if you’re using bash, you could also say:

tr -d $'\r' < inputfile

Leave a Comment