我正在编写一个 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
有什么帮助吗?