Reputation: 263
is there a way for diff to return the filenames of the files being compared aswell as the output, for example:
instead of :
17c17
< free ((qu -> vals) - 1);
---
> free (qu -> vals);
I am looking for:
17c17
file1.c
< free ((qu -> vals) - 1);
---
file2.c
> free (qu -> vals);
is it possible?
THanks
Upvotes: 3
Views: 1348
Reputation: 3504
the -u
switch does include the filenames:
#!/bin/bash
echo " free ((qu -> vals) - 1);" > file1.c
echo " free (qu -> vals);" > file2.c
diff -u file1.c file2.c
output:
--- file1.c 2014-03-13 17:46:43.000000000 -0500
+++ file2.c 2014-03-13 17:46:43.000000000 -0500
@@ -1 +1 @@
- free ((qu -> vals) - 1);
+ free (qu -> vals);
Upvotes: 3