开发者社区 问答 正文

这是个很有意思的问题:Linux下将文本中的`\r\n`转换成换行的效果

环境
ubuntu 14.04 64bit
vim
包含大量rn的文本
问题描述
text1:

ssh_connect: needpriv 0   \r\n   debug1: Connecting to 192.168.10.130 [192.168.10.130]
port 22.   \r\n   debug2: fd 3 setting O_NONBLOCK   \r\n  debug1: fd 3 clearing 
O_NONBLOCK   \r\n   debug1: Connection established.   \r\   ndebug3: timeout: 10000 ms 
remain after connect\r\ndebug1: permanently_set_uid: 0/0\r\ndebug1: identity file 
......
说明:上面摘自错误输出,阅读起来很不友好。因为包含大量的\r\n(我用空格标记了),我把他们复制粘帖到vim,atom,gedit上\r\n都不会转换为换行效果。现在我想让\r\n转换成换行效果,如下:

ssh_connect: needpriv 0
debug1: Connecting to 192.168.10.130 [192.168.10.130]port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug3: timeout: 10000 ms 
remain after connect
debug1: permanently_set_uid: 0/0
debug1: identity file 
请问大家有什么好的办法

展开
收起
a123456678 2016-06-24 15:05:44 3901 分享 版权
1 条回答
写回答
取消 提交回答
  • 使用 vim 的话::%s+\r\n+^M+g,其中^M使用Ctrl+v加Enter输入。

    2019-07-17 19:47:01
    赞同 展开评论
问答标签:
问答地址: