a.txt
1
2
3
4
5
6
b.txt
10
2
3
40
50
6
70
I'd like to run some command on these files that generates the following output.
10
40
50
70
How can I run a diff on two files but only show lines that changed. I don't want any other metadata around the output.
I also don't want to see any context around the changed lines.
Try
comm -1 -3 a.txt b.txt
comm, common lines, is a handy command.
Actually I like Brian's answer using "comm" a lot. It was new to me and works for me.
My more complicated method would be to use a chain of diff, grep and then sed to remove the first two characters.
diff a.txt b.txt | grep ">" | sed s/..//
Not beautiful, not bullet-proof, but a quick hack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With