Replace ^M in lines

Sometimes when editing a file which was created on a machine other then your Linux machine, each line ends up with a visible ^M (CTRL + M). To remove this at each line you can use vi. In vi you can escape a control character by preceding it with a ^V (CTRL + V). Now using the search and replace command you can easily change the ^M (CTRL + M) in all lines. Change vi to the escape mode and type
CTRL+V and CTRL+M, this will look on your screen as:

Please login first before adding a comment.


You are here: Home Howtos and FAQs Bash Replace ^M in lines