linux - 修补 csv 文件会生成错误

标签 linux diff

我有两个 CSV 文件,即 test1.csvtest2.csv,由自定义分隔符管道符号 (|) 分隔。我通过 diff 命令获取他们的更改,如下所示

diff test2.csv test1.csv > test.patch

现在我要做的就是创建第三个文件 test.csv 并按如下方式运行补丁

patch test.csv < test.patch

但是当我运行此补丁命令时,出现以下错误。

patching file test.csv
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file test.csv.rej

你能告诉我这个方法有什么问题吗?

  • 编辑: 我有两个名为 test1.csv 和 test2.csv 的文件。 命令按以下方式执行

diff test2.csv test1.csv > test.patch

(after patch creation i create a new file 'test.csv')

patch test.csv < test.patch

最佳答案

在你的前任中。 test.csv 应类似于 test2.csv。请看下面的示例。

 $ cat f1.csv
a
b
c
z
 $ cat f3.csv
a
b
c
d
 $ diff f1.csv f3.csv  > diffop
 $ cp f1.csv tst
 $ cat tst
a
b
c
z
 $ patch tst diffop
patching file tst
 $ cat tst
a
b
c
d

关于linux - 修补 csv 文件会生成错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11929719/

相关文章:

unix - 使用unix比较远程服务器上两个目录的内容

c# - 查找两个 json 对象之间的差异

python - 解析 DeepDiff 结果

SVN 差异 - 选项 ' --summarize '

regex - ansible lineinfile 模块用多行替换单行

linux - 如何用以特定数字开头的数字替换文件名?

c - 允许某些进程读写目录并拒绝其余所有进程

linux - 为什么这个 "hello world"golang http 示例在 osx 上变慢

python - 使用 emacs/python/winmerge 跨两个 diff 文件映射行号

linux - 我如何知道 Linux 进程正在等待什么?