git 如何区分microsoft word文档?
In git how to diff microsoft word documents?
我一直在关注 this guide here 如何区分 Microsoft Word 文档,但我 运行 遇到了这个错误:
Usage: /usr/bin/docx2txt.pl [infile.docx|-|-h] [outfile.txt|-]
/usr/bin/docx2txt.pl < infile.docx
/usr/bin/docx2txt.pl < infile.docx > outfile.txt
In second usage, output is dumped on STDOUT.
Use '-h' as the first argument to get this usage information.
Use '-' as the infile name to read the docx file from STDIN.
Use '-' as the outfile name to dump the text on STDOUT.
Output is saved in infile.txt if second argument is omitted.
Note: infile.docx can also be a directory name holding the unzipped content
of concerned .docx file.
fatal: unable to read files to diff
为了解释我是如何得出这个错误的:我在我想要区分的存储库中创建了一个 .git 属性。 .git属性看起来像这样:
*.docx diff=word
*.docx difftool=word
我已经安装了 docx2txt。我在 Linux。我创建了一个名为 docx2txt 的文件,其中包含:
#!/bin/bash
docx2txt.pl -
我 $ chmod a+x
docx2txt 并且我把 docx2txt 放在 /usr/bin/
我做到了:
$ git config diff.word.textconv docx2txt
然后尝试比较两个 Microsoft Word 文档。那是我遇到上面提到的错误的时候。
我错过了什么?我该如何解决这个错误?
PS:我不知道我的 shell 是否可以找到 docx2txt,因为当我这样做时:
$ docx2txt
我的终端冻结,正在处理一些东西,但没有输出任何东西,当我执行这些命令时,发生了这种情况:
$ man docx2txt
No manual entry for docx2txt
$ docx2txt --help
Can't read docx file <--help>!
更新进度:我将 docx2txt 更改为
#!/bin/bash
docx2txt.pl "" -
如 pmod 所建议的那样,现在 git diff <commit>
可从命令行运行!耶!
然而,当我尝试
$ git difftool <commit>
git 启动 kdiff3,我得到这个弹出错误:
Some input characters could not be converted to valid unicode.
You might be using the wrong codec. (e.g. UTF-8 for non UTF-8 files).
Don't save the result if unsure. Continue at your own risk.
Affected input files are in A, B.
...文件中的所有字符都是胡言乱语。命令行正确显示 diff 文本,但 kdiff3 出于某种原因无法正确显示 diff 中的文本。
如何在 kdiff3 或其他 gui 工具中正确显示 diff 的文本?我应该将 kdiff3 更改为其他工具吗?
Extra:我的 shell 似乎无法找到 docx2txt,因为这些命令:
$ which doctxt
which: no doctxt in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
$ which docx2txt
/usr/bin/docx2txt
doc2txt.pl 根据用法需要恰好两个参数或零。在第一个(您的)案例中,参数是文件名或“-”。因此,当文件名中至少有一个 space 作为第一个参数传递时,您的包装脚本看起来是正确的。在这种情况下,在 $1 扩展后,文件名部分将作为单独的参数传递,因此工具会输出使用信息,因为它会读取超过 2 个参数。
尝试使用引号来避免文件名拆分:
#!/bin/bash
docx2txt.pl "" -
PS: I don't know if my shell can find docx2txt
你可以用
检查这个
$ which docx2txt
如果看到路径,则可以找到工具(二进制或可运行脚本)(基于 PATH 环境变量)。
because when I do this:
$ docx2txt
my terminal freezes, processing something, but doesn't output anything
如果没有参数,您的脚本将执行 doc2txt.pl -,根据工具的用法,它期望通过 STDIN 传递输入文件,即您正在输入的内容。因此,它看起来像是挂起和处理某些东西,但实际上只捕获您的输入。
可以使用pandoc转markdown
pandoc -f docx -t markdown -o outfile.md infile.docx
然后使用 meld 来比较文档
https://askubuntu.com/questions/515900/how-to-compare-two-files
我一直在关注 this guide here 如何区分 Microsoft Word 文档,但我 运行 遇到了这个错误:
Usage: /usr/bin/docx2txt.pl [infile.docx|-|-h] [outfile.txt|-]
/usr/bin/docx2txt.pl < infile.docx
/usr/bin/docx2txt.pl < infile.docx > outfile.txt
In second usage, output is dumped on STDOUT.
Use '-h' as the first argument to get this usage information.
Use '-' as the infile name to read the docx file from STDIN.
Use '-' as the outfile name to dump the text on STDOUT.
Output is saved in infile.txt if second argument is omitted.
Note: infile.docx can also be a directory name holding the unzipped content
of concerned .docx file.
fatal: unable to read files to diff
为了解释我是如何得出这个错误的:我在我想要区分的存储库中创建了一个 .git 属性。 .git属性看起来像这样:
*.docx diff=word
*.docx difftool=word
我已经安装了 docx2txt。我在 Linux。我创建了一个名为 docx2txt 的文件,其中包含:
#!/bin/bash
docx2txt.pl -
我 $ chmod a+x
docx2txt 并且我把 docx2txt 放在 /usr/bin/
我做到了:
$ git config diff.word.textconv docx2txt
然后尝试比较两个 Microsoft Word 文档。那是我遇到上面提到的错误的时候。
我错过了什么?我该如何解决这个错误?
PS:我不知道我的 shell 是否可以找到 docx2txt,因为当我这样做时:
$ docx2txt
我的终端冻结,正在处理一些东西,但没有输出任何东西,当我执行这些命令时,发生了这种情况:
$ man docx2txt
No manual entry for docx2txt
$ docx2txt --help
Can't read docx file <--help>!
更新进度:我将 docx2txt 更改为
#!/bin/bash
docx2txt.pl "" -
如 pmod 所建议的那样,现在 git diff <commit>
可从命令行运行!耶!
然而,当我尝试
$ git difftool <commit>
git 启动 kdiff3,我得到这个弹出错误:
Some input characters could not be converted to valid unicode.
You might be using the wrong codec. (e.g. UTF-8 for non UTF-8 files).
Don't save the result if unsure. Continue at your own risk.
Affected input files are in A, B.
...文件中的所有字符都是胡言乱语。命令行正确显示 diff 文本,但 kdiff3 出于某种原因无法正确显示 diff 中的文本。
如何在 kdiff3 或其他 gui 工具中正确显示 diff 的文本?我应该将 kdiff3 更改为其他工具吗?
Extra:我的 shell 似乎无法找到 docx2txt,因为这些命令:
$ which doctxt
which: no doctxt in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
$ which docx2txt
/usr/bin/docx2txt
doc2txt.pl 根据用法需要恰好两个参数或零。在第一个(您的)案例中,参数是文件名或“-”。因此,当文件名中至少有一个 space 作为第一个参数传递时,您的包装脚本看起来是正确的。在这种情况下,在 $1 扩展后,文件名部分将作为单独的参数传递,因此工具会输出使用信息,因为它会读取超过 2 个参数。
尝试使用引号来避免文件名拆分:
#!/bin/bash
docx2txt.pl "" -
PS: I don't know if my shell can find docx2txt
你可以用
检查这个$ which docx2txt
如果看到路径,则可以找到工具(二进制或可运行脚本)(基于 PATH 环境变量)。
because when I do this:
$ docx2txt
my terminal freezes, processing something, but doesn't output anything
如果没有参数,您的脚本将执行 doc2txt.pl -,根据工具的用法,它期望通过 STDIN 传递输入文件,即您正在输入的内容。因此,它看起来像是挂起和处理某些东西,但实际上只捕获您的输入。
可以使用pandoc转markdown
pandoc -f docx -t markdown -o outfile.md infile.docx
然后使用 meld 来比较文档
https://askubuntu.com/questions/515900/how-to-compare-two-files