Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 4
    These two are not identical. The first with replace '\r\n' with '\n' (effectively), but the second will remove all '\r' wherever they appear. It's uncommon for carriage-return to appear in a text file, other than at the end of the line, but it can happen. Commented Jun 30, 2014 at 16:56
  • 1
    Usage: sed 's/\r$//' input_file.txt > output_file.txt Commented Jun 27, 2020 at 9:18
  • Why is it \r$ and not \r\n/\n? I mean where does it replace against \n? Commented Jan 3, 2023 at 11:08
  • Ah ok $ is line-ending, which means "remove \r from the end of the line". Commented Jan 3, 2023 at 11:19