gpt4 book ai didi

bash - 如何将文件名附加到统一差异标签

转载 作者:行者123 更新时间:2023-12-05 04:14:54 25 4
gpt4 key购买 nike

我正在编写一个 bash 脚本,它需要显示远程文件和我的本地副本之间的差异。我正在通过命令执行此操作:

filepath=/home/user/test.txt
ssh $REMOTE_USER cat $filepath | diff -bu --label="remote" --label="local" - $filepath

这会生成如下内容:

--- remote
+++ local

@@ -2,7 +2,7 @@
--- This is a line
+++ This is something else

我想在标签中包含 $filepath 值,但我不知道这是否可行或如何实现。像这样:

--- remote /home/user/test.txt
+++ local /home/user/test.txt
@@ -2,7 +2,7 @@
--- This is a line
+++ This is something else

有什么帮助吗?

最佳答案

这就是我在疲倦时发帖的收获。我只是将 $filepath 添加到 --label 选项中,如下所示:

... --label="remote $filepath" --label="local $filepath"

嘘!

关于bash - 如何将文件名附加到统一差异标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33746928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com