I used diff --from-file
to compare my Riak dev1 config to the three others.
diff --from-file ~/riak/dev/dev1/etc/app.config \
~/riak/dev/dev2/etc/app.config \
~/riak/dev/dev3/etc/app.config \
~/riak/dev/dev4/etc/app.config
It shows the configs differ only in the port number setting (8091, 8092, 8093, 8094).
It's hard to tell where one file ends and the next begins because the output doesn't contain file names.
11c11
< {http, [ {"127.0.0.1", 8091 } ]},
---
> {http, [ {"127.0.0.1", 8092 } ]},
15c15
< %{https, [{ "127.0.0.1", 8091 }]},
---
> %{https, [{ "127.0.0.1", 8092 }]},
26c26
< {handoff_port, 8101 },
---
> {handoff_port, 8102 },
54c54
< {pb_port, 8081 },
---
> {pb_port, 8082 },
11c11
< {http, [ {"127.0.0.1", 8091 } ]},
---
> {http, [ {"127.0.0.1", 8093 } ]},
15c15
< %{https, [{ "127.0.0.1", 8091 }]},
---
> %{https, [{ "127.0.0.1", 8093 }]},
26c26
< {handoff_port, 8101 },
---
> {handoff_port, 8103 },
54c54
< {pb_port, 8081 },
---
> {pb_port, 8083 },
11c11
< {http, [ {"127.0.0.1", 8091 } ]},
---
> {http, [ {"127.0.0.1", 8094 } ]},
15c15
< %{https, [{ "127.0.0.1", 8091 }]},
---
> %{https, [{ "127.0.0.1", 8094 }]},
26c26
< {handoff_port, 8101 },
---
> {handoff_port, 8104 },
54c54
< {pb_port, 8081 },
---
> {pb_port, 8084 },
Before each "11c11" line, I'd like to see the names of the two files being comared.
git diff
can produce output like this:
--- a/home/sandport/riak/dev/dev1/etc/app.config
+++ b/home/sandport/riak/dev/dev2/etc/app.config
How would you do it with standard diff?
Best Answer
Add the parameter
--unified=0
to show the names of each file.The
--unified
part sets the output format to 'unified'. The unified format starts with the names of the files being compared.The
=0
part hides the context lines. It makes the output easier to inspect visually.Rerun the original command with the new parameter and the output will look like this: