How can I diff two files and get what is different in the second one as an output

1

What's easiest way to diff two files, check what is different in the second one and get it as output? I'm comparing two css files, and rest is the same only colors are different.

PS: I also want to keep the scope they are in.

Nika Tomadze

Posted 2016-02-03T18:41:23.650

Reputation: 163

Answers

2

It may be that you are after: diff -u f1 f2 > fpatch ; patch -i fpatch -o f2diff

aphorise

Posted 2016-02-03T18:41:23.650

Reputation: 136

1

If you are trying to do this in Windows, the command fc might do what you want. Something like fc firstfile.xxx secondfile.xxx > output.txt the > will create the file output.txt and if you run the command again it will clear everything that was there and start the file over. Two >> will append to the end of the file. If they are in different locations and the path has spaces you will have to do it like this fc "first folder\first file.xxx" "second folder\second file" >> "some other folder\output.txt" the command in Linux is simply diff but I don't know the syntax for that, here is a link to the syntax

Cand3r

Posted 2016-02-03T18:41:23.650

Reputation: 2 629

Your redirection is not quite right... Using double >> will cause the output to be appended to an existing file. If no file exists, one will be created. A single > will cause a new file to be created to receive the output. If one already exists, it will be overwritten. These behaviors generally hold for both Unix and Windows. – BillP3rd – 2016-02-04T01:40:50.483

Yup, totally swapped those, will edit, lol i write these i batch files at least monthly and still didnt catch that – Cand3r – 2016-02-04T01:42:30.327