且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换包含CRLF字符串?

更新时间:2022-11-22 13:03:34

您可以使用SED装饰用{CRLF}月底所有行:

You can use sed to decorate all rows with a {CRLF} at end:

sed 's/$/<CRLF>/'

然后删除所有\\ r \\ n与TR

then remove all \r\n with tr

| tr -d "\r\n"

然后更换双CRLF与\\ n

and then replace double CRLF's with \n

| sed 's/<CRLF><CRLF>/\n/g'

和去除剩余的CRLF的。

and remove leftover CRLF's.

有是一个单行的sed这做这一切在一个周期内,但我似乎现在不能找到它。

There was an one-liner sed which did all this in a single cycle, but I can't seem to find it now.