2

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

有什么帮助吗?

4

1 回答 1

1

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

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

嘘!

于 2015-11-17T00:21:58.600 回答