2015-11-17 37 views
1

我在寫一個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 

我想有包括在標籤中的$文件路徑值,但我不知道這是可能的或如何去做。類似這樣的:

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

任何幫助?

回答

1

這是我得到的時候累了。我簡單地將$ filepath添加到--label選項中,如下所示:

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

Sheesh!

+0

由於這是一個錯字類型的問題,不可能在未來幫助任何人,所以我建議您刪除該問題。 – 4ae1e1