【发布时间】:2013-05-12 12:03:31
【问题描述】:
我有一个带有 unix eol 的文件 file1in,
我有一个脚本可以在其中进行一些编辑,但编辑是在output.txt 中完成的,并重命名为file1,这会将 eol 更改为 windows/dos
代码已给出
set uu=file1
set vv=file2
setlocal EnableDelayedExpansion
(for /F "delims=" %%a in (%uu%) do (
set "line=%%a"
if "!line:345=!" neq "!line!" (
if "!line:123=!" neq "!line!" (
if not defined flag (
findstr "123" %vv% | findstr "345"
set flag=true
)
) else (
echo !line!
)
) else (
echo !line!
)
)) >output.txt
del %uu%
rename output.txt file1
有什么方法可以在没有用户输入的情况下通过 cmd 将其改回或保留 unix eol?
试过直接输入file1,得到一个0 kb的文件
试过type output.txt>file1给了dos/win eol
回显除空行以外的任何内容echo.>file1 更改了 eol 字符
【问题讨论】:
-
你使用什么语言?
-
“unix”的 eol 是什么意思(例如 CR only、CRLFCR)?
-
使用批处理脚本。 @endoro,真的不知道,直到现在我才使用 notepad++ 并将 EOL 覆盖从 windows/dos 更改为 unix/osx 格式。
-
试过wiki,它说LF
-
这是windows eol ` `