【问题标题】:print the file output without ^M [duplicate]打印不带 ^M 的文件输出 [重复]
【发布时间】:2015-05-20 14:50:45
【问题描述】:

我有一个包含 ^M 字符的文件

HTTP/1.1 200 OK^M
HOST_SERVICE: FutureTenseContentServer:11.1.1.8.0^M
Transfer-Encoding: chunked^M
Date: Wed, 20 May 2015 02:00:04 GMT^M
Content-Type: text/html; charset=UTF-8^M
X-Powered-By: Servlet/2.5 JSP/2.1^M
^M
^M
^M
^M
^M

我需要在不使用 ^M 的情况下使用 cat 或任何 linux 命令打印此文件的输出。

谢谢, 拉维

【问题讨论】:

标签: linux cat


【解决方案1】:

对于延迟我真的很抱歉,我使用 sed 和管道它会删除最新的五个空行

 sed 's/[\^\][M]//' file | head -n 6 > file

输出会是这样的

HTTP/1.1 200 OK
HOST_SERVICE: FutureTenseContentServer:11.1.1.8.0
Transfer-Encoding: chunked
Date: Wed, 20 May 2015 02:00:04 GMT
Content-Type: text/html; charset=UTF-8
X-Powered-By: Servlet/2.5 JSP/2.1

【讨论】:

  • 如何删除行而不是空格
  • 上述命令在一行中显示输出
  • 以后,请务必在您的回答中提供解释。
猜你喜欢
  • 1970-01-01
  • 2011-12-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-10
相关资源
最近更新 更多