Does anyone have a trick to run sdiff to display the filenames as a header?

Hi,

Does anyone know if there is anyway to run sdiff such that it shows the name of the files as it display the results of the differences? That is, I want it to show the filenames on each column and then display the differences
I can't find any option that allows this. Maybe someone has a trick of some sort to make this happen?
If not sdiff, maybe there is another command that I can use that functions the same as sdiff but does what am after?

$ sdiff --version
sdiff (GNU diffutils) 2.8.1
Copyright (C) 2002 Free Software Foundation, Inc.

This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Written by Thomas Lord.

So the output from sdiff looks like the output from diff -y to me. I've not seen any options in them or comm that would help.

It depends what you are trying to achieve on how we approach this. They all just want two files, so I'm hoping you either know the file names or use variable in a script to run sdiff already.

You might have some joy with something like:-

printf "\nDifferences in file1\n=====================\n"
diff file1 file2 | grep -E "^<" | sed 's/^< //'
printf "\nDifferences in file1\n=====================\n"
diff file1 file2 | grep -E "^>" | sed 's/^> //'

It's not pretty, but that might give you what you need.

If this doesn't deliver, can you show us some sample input and desired output along with any thing you have tried and why they do not give you what you want.

Thanks, in advance,
Robin

How about - if your shell offers "process substitution" -

sdiff <(echo file3; cat file3) <(echo file3~; cat file3~)
file3                                                         |  file3~
DISTANCIA1.45_SIMETRIA1_GIRO2_ACTIVOS11/MoN-MVW.out:::   Tota    DISTANCIA1.45_SIMETRIA1_GIRO2_ACTIVOS11/MoN-MVW.out:::   Tota
DISTANCIA1.45_SIMETRIA1_GIRO2_ACTIVOS7/MoN-MVW.out:::    Tota    DISTANCIA1.45_SIMETRIA1_GIRO2_ACTIVOS7/MoN-MVW.out:::    Tota
DISTANCIA1.45_SIMETRIA1_GIRO2_ACTIVOS9/MoN-MVW.out:::    Tota    DISTANCIA1.45_SIMETRIA1_GIRO2_ACTIVOS9/MoN-MVW.out:::    Tota
DISTANCIA1.45_SIMETRIA1_GIRO4_ACTIVOS11/MoN-MVW.out:::   Tota    DISTANCIA1.45_SIMETRIA1_GIRO4_ACTIVOS11/MoN-MVW.out:::   Tota
DISTANCIA1.45_SIMETRIA1_GIRO1_ACTIVOS11/MoN-MVW.out:::   Tota <
1 Like