在 vi 编辑器中创建的 .txt 文件的输出在一行中显示所有文本
The output of a .txt file created in vi editor show all the text in one line
我有一个日志文件供我的脚本获取报告,即 report.txt 文件。当我在 vi 编辑器中看到它时,它显示为我想要的样子:
Sanity Report
Start time:Fri Mar 10 08:08:33 CST 2017
LABS:
1: lht1-u0 (172.28.152.240)
2: lht1-u1 (172.28.152.241)
BUILDS:
CCM: 455
AMM: 395
OEBase: 864
ACS_DM: 569
AMS_DM: 707
TC Area TC Title Status
System-VM0 install ------------------------------------- Passed
System-VM1 install ------------------------------------- Passed
OpensSaf start ----------------------------- Passed
Verify alarmd server is -------------------------------- Passed
Product install of AMM ------------------------- Passed
Product install of AMM ------------------------- Passed
但是当我打开 windows 中的实际文本文件时(该文件应该通过电子邮件发送给一组人),它会在一行中显示所有文本。
我该如何更改?
这可能与行尾字符有关。
据我所知,在 Unix 和 Windows 上,约定不同。
DOS / Windows 使用:
\r\n
仅限 Unix:
\n
您需要一种方法将 unix 风格的行尾转换为 windows 风格。
使用正则表达式引擎可以解决问题。
我找到了自己的答案。我在这里 https://www.maketecheasier.com/convert-files-from-linux-format-windows/ 找到它并且我使用了 awk 'sub("$", "\r")' uniz.txt > windows.txt 效果很好!
对于拥有此类文件但无法访问 Linux 的任何人,请使用写字板打开文件(进行更改??)并保存。
下次用记事本打开就正常了
我有一个日志文件供我的脚本获取报告,即 report.txt 文件。当我在 vi 编辑器中看到它时,它显示为我想要的样子:
Sanity Report
Start time:Fri Mar 10 08:08:33 CST 2017
LABS:
1: lht1-u0 (172.28.152.240)
2: lht1-u1 (172.28.152.241)
BUILDS:
CCM: 455
AMM: 395
OEBase: 864
ACS_DM: 569
AMS_DM: 707
TC Area TC Title Status
System-VM0 install ------------------------------------- Passed
System-VM1 install ------------------------------------- Passed
OpensSaf start ----------------------------- Passed
Verify alarmd server is -------------------------------- Passed
Product install of AMM ------------------------- Passed
Product install of AMM ------------------------- Passed
但是当我打开 windows 中的实际文本文件时(该文件应该通过电子邮件发送给一组人),它会在一行中显示所有文本。 我该如何更改?
这可能与行尾字符有关。 据我所知,在 Unix 和 Windows 上,约定不同。
DOS / Windows 使用:
\r\n
仅限 Unix:
\n
您需要一种方法将 unix 风格的行尾转换为 windows 风格。
使用正则表达式引擎可以解决问题。
我找到了自己的答案。我在这里 https://www.maketecheasier.com/convert-files-from-linux-format-windows/ 找到它并且我使用了 awk 'sub("$", "\r")' uniz.txt > windows.txt 效果很好!
对于拥有此类文件但无法访问 Linux 的任何人,请使用写字板打开文件(进行更改??)并保存。
下次用记事本打开就正常了