<body>
<code>vim hello.txt# 输入hello# :wq 保存退出cat hello.txt</code>
结果是这样的:
然而:
<code>echo -n "hello" > hello.txtcat hello.txt</code>
结果是这样的:
没错, 此时的cat有终止标记, 且file会显示with no line terminators
但此时用vim一编辑, 再保存, 又有了行终止符.
使用nano可以看到这个换行符, 但是我不会也不常用nano啊(别见笑)
— 以下内容与主题无关, 只是描述下事故背景 —
这个问题导致我在nginx使用ssi时,多出了个换行符,以至于样式和js的地址拼接换行, 多数浏览器无法正常加载.
<code><link type="text/css" href="<!---ecms #include virtual='/inc/cdn.inc'-->/public/index.css?v=<!---ecms #include virtual='/inc/version.inc" /></code>
file: cdn.inc, 因手动vim编辑了该文件, 导致网站多数用户样式挂了却未发觉(多出了换行符)
<code>mydomain.com</code>
file: version.inc, 上线时脚本会更新该文件, 用于清浏览器缓存
<code>1477452280307</code>
回复内容:
<body>
<code>vim hello.txt# 输入hello# :wq 保存退出cat hello.txt</code>
结果是这样的:
然而:
<code>echo -n "hello" > hello.txtcat hello.t<i>1本文来#源gaodai$ma#com搞$代*码*网</i><pre>搞代gaodaima码
xt
结果是这样的:
没错, 此时的cat有终止标记, 且file会显示with no line terminators
但此时用vim一编辑, 再保存, 又有了行终止符.
使用nano可以看到这个换行符, 但是我不会也不常用nano啊(别见笑)
– 以下内容与主题无关, 只是描述下事故背景 –
这个问题导致我在nginx使用ssi时,多出了个换行符,以至于样式和js的地址拼接换行, 多数浏览器无法正常加载.
<code><link type="text/css" href="-ecms #include virtual='/inc/cdn.inc'-->/public/index.css?v=<!---ecms #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好像没关系-。–>