作者热门文章
- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我是一名 Java 开发人员,我正在使用 Ubuntu 进行开发。该项目是在 Windows 中使用 Eclipse 创建的,它使用 Windows-1252编码。
为了转换为 UTF-8,我使用了 recode 程序:
find Web -iname \*.java | xargs recode CP1252...UTF-8
这个命令给出了这个错误:
recode: Web/src/br/cits/projeto/geral/presentation/GravacaoMessageHelper.java failed: Ambiguous output in step `CR-LF..data
我已经搜索并在 Bash and Windows, Recode: Ambiguous output in step `data..CR-LF' 中找到了解决方案 它说:
Convert line endings from CR/LF to asingle LF: Edit the file with Vim,give the command
:set ff=unix
and savethe file. Recode now should runwithout errors.
很好,但我有很多文件要从中删除 CR/LF 字符,而且我无法打开每个文件来执行此操作。 Vi 没有为 Bash 操作提供任何命令行选项。
可以使用 sed 来执行此操作吗?怎么样?
最佳答案
应该有一个名为 dos2unix
的程序会为您修复行尾。如果它还没有在你的 Linux 机器上,它应该可以通过包管理器获得。
关于windows - 如何在 Unix 行尾转换 Windows 行尾(CR/LF 到 LF),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3891076/
我是一名优秀的程序员,十分优秀!