<code>vim hello.txt # 输入hello # :wq 保存退出 cat hello.txt</code>
结果是这样的:
然而:
<code>echo -n "hello" > hello.txt cat hello.txt</code>
结果是这样的:
没错, 此时的cat有终止标记, 且file会显示with no line terminators
但此时用vim一编辑, 再保存, 又有了行终止符.
使用nano可以看到这个换行符, 但是我不会也不常用nano啊(别见笑)
-- 以下内容与主题无关, 只是描述下事故背景 --
这个问题导致我在nginx使用ssi时,多出了个换行符,以至于样式和js的地址拼接换行, 多数浏览器无法正常加载.
<code><link type="text/css" href="<!--#include virtual='/inc/cdn.inc'-->/public/index.css?v=<!--#include virtual='/inc/version.inc" /></code>
file: cdn.inc, 因手动vim编辑了该文件, 导致网站多数用户样式挂了却未发觉(多出了换行符)
<code>mydomain.com</code>
file: version.inc, 上线时脚本会更新该文件, 用于清浏览器缓存
<code>1477452280307</code>
<code>vim hello.txt # 输入hello # :wq 保存退出 cat hello.txt</code>
结果是这样的:
然而:
<code>echo -n "hello" > hello.txt cat hello.txt</code>
结果是这样的:
没错, 此时的cat有终止标记, 且file会显示with no line terminators
但此时用vim一编辑, 再保存, 又有了行终止符.
使用nano可以看到这个换行符, 但是我不会也不常用nano啊(别见笑)
-- 以下内容与主题无关, 只是描述下事故背景 --
这个问题导致我在nginx使用ssi时,多出了个换行符,以至于样式和js的地址拼接换行, 多数浏览器无法正常加载.
<code><link type="text/css" href="<!--#include virtual='/inc/cdn.inc'-->/public/index.css?v=<!--#include virtual='/inc/version.inc" /></code>
file: cdn.inc, 因手动vim编辑了该文件, 导致网站多数用户样式挂了却未发觉(多出了换行符)
<code>mydomain.com</code>
file: version.inc, 上线时脚本会更新该文件, 用于清浏览器缓存
<code>1477452280307</code>
<code>:set noendofline binary :w</code>
查看一下set ff是否设置为了dos
linux的话,一般都是set ff=unix的配置吧?
----- 编辑----
实验了一下,跟ff好像没关系-。-
                        
                        每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号