I have two files and a shell script.
File 1:
Batman
Superman
John Snow
Jack Sparrow
Rob Stark
File 2:
Batman
Ironman
Superman
Spiderman
John Snow
Arya Stark
Jack Sparrow
Rob Stark
The hound
Script:
#!/bin/bash
sort ~/Desktop/file1.txt > ~/Desktop/fileA.txt
sort ~/Desktop/file2.txt > ~/Desktop/fileB.txt
diff -y ~/Desktop/fileA.txt ~/Desktop/fileB.txt > ~/Desktop/diff.txt
The script runs absolutely fine, the output is:
> Arya Stark
Batman Batman
> Ironman
Jack Sparrow Jack Sparrow
John Snow John Snow
Rob Stark Rob Stark
> Spiderman
Superman Superman
> The hound
But I want to output to automatically be:
File A File B
> Arya Stark
Batman Batman
> Ironman
Jack Sparrow Jack Sparrow
John Snow John Snow
Rob Stark Rob Stark
> Spiderman
Superman Superman
> The hound
Whats the best way to so it using diff command only?