如何将文件名附加到统一的差异标签中

3

我正在编写一个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

需要帮忙吗?

1个回答

3
这就是当我疲劳时发布文章的结果。我只需像这样将$filepath添加到--label选项中:
... --label="remote $filepath" --label="local $filepath"

天啊!


由于这是一个笔误类的问题,而且不太可能对未来的任何人有所帮助,我建议您删除这个问题。 - 4ae1e1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接