在Linux中使用不同目录中的文件应用补丁命令
我正在尝试使用不同目录中的 2 个文件来应用补丁。输出文件也应该位于不同的目录中。第一个文件位于 /var/local/documents/document.xml 中,补丁文件位于 /var/local/patches/patch.diff 中,我想要输出文件应在 /var/local/final/final.xml 中创建。
当文件位于同一目录中时,此命令有效:
patch document.xml -i patch.diff -o final.xml
但是当它们位于不同的目录中时,我尝试使用以下命令:
补丁 /var/local/documents/document.xml -i /var/local/patches/patch.diff -o /var/local/final/final.xml
我收到以下错误:
(Stripping trailing CRs from patch.)
patching file {file}
Hunk#1 FAILED at 20.
1 out of 1 hunk FAILED -- saving rejects to file {file}
我在某处读到我应该使用 -d 和 -p 来正确处理目录,但我不知道应该如何做...
I'm trying to apply a patch using 2 files in different directories. The output file should be in a different directory too. The first file is in /var/local/documents/document.xml and patch file is located in /var/local/patches/patch.diff and I want the output file should be created in /var/local/final/final.xml.
When the files are located in the same directory, this command works:
patch document.xml -i patch.diff -o final.xml
But when they are in separate directories and I try to use the following command:
patch
/var/local/documents/document.xml -i
/var/local/patches/patch.diff -o
/var/local/final/final.xml
I get the following error:
(Stripping trailing CRs from patch.)
patching file {file}
Hunk#1 FAILED at 20.
1 out of 1 hunk FAILED -- saving rejects to file {file}
I've read somewhere that I should use -d and -p to work correctly with directories but I have no clue how I should do it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,它是 -p 开关(在您的情况下,它应该从补丁路径中删除 2 个条目):
Yes, it's -p switch (in your case it should strip 2 entries from patch path):
试试这个:
Try this: