How to append filename to a unified diff label

861 Views Asked by At

I am writing a bash script that needs to display a diff between a remote file and my local copy. I am doing this through a command:

filepath=/home/user/test.txt
ssh $REMOTE_USER cat $filepath | diff -bu --label="remote" --label="local" - $filepath

This generates something like:

--- remote
+++ local

@@ -2,7 +2,7 @@
--- This is a line
+++ This is something else

I would like to have the $filepath value included in the label but I don't know if this is possible or how to do it. Something like this:

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

Any Help?

1

There are 1 best solutions below

1
On

This is what I get for posting while tired. I simply added $filepath to the --label option as in:

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

Sheesh!