sed: How can I replace \r\r\n?

5,606

Solution 1

It turns out that replacing \r\r\n by \n is fairly simple:

sed 's/\r\r$//g'

Solution 2

sed ':a;N;$!ba;s/\r\r\n//g'

This will replace "\r\n\n" with nothing (that is remove it), while in the example was replacing \n with a space so:

sed ':a;N;$!ba;s/\r\r\n/ /g'
Share:
5,606

Related videos on Youtube

Mel
Author by

Mel

Updated on September 18, 2022

Comments

  • Mel
    Mel over 1 year

    In this question on stackoverflow it is explained how one can replace a newline character using sed.

    My problem is that I want to replace the character sequence \r\r\n with sed. Can somebody help me adapt the example given in the referenced question?