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