Questions tagged [diff]

diff is a shell command to find differences between two files. It is common on all *nix based systems

In computing, diff is a file comparison utility that outputs the differences between two files. It is typically used to show the changes between one version of a file and a former version of the same file.
Diff displays the changes made per line for text files.

The output is called a "diff", or a patch, since the output can be applied with the Unix program patch. The output of similar file comparison utilities are also called a "diff".

(source)

Type man diff in a shell to get full documentation.

298 questions
492
votes
18 answers

How do I compare binary files in Linux?

I need to compare two binary files and get the output in the form for every different byte. So if file1.bin is 00 90 00 11 in binary form and file2.bin is 00 91 00 10 I want to get something…
frustratedCmpNoLongerUser
115
votes
10 answers

How can I diff two XML files?

On Linux, how could I generate a diff between two XML files? Ideally, I would like to be able configure it to some things strict, or loosen some things, like whitespace, or attribute order. I'll often care that the files are functionally the same,…
qedi
  • 1,681
113
votes
2 answers

Ignore .svn when doing `diff -r`

diff has an option --recursive (-r) to do a comparison between two directories (the files inside them). Is there a way to make diff ignore certain sub-directories (eg: .svn)? $ diff -r src1/ src2/
89
votes
6 answers

How can I diff binary files in git?

In order to diff binary files in git, I assume I need to set up a difftool. What difftools work? How do you put the parameters in?
69
votes
13 answers

Linux: Compare Directory Structure Without Comparing Files

What is the best and simplest way to compare two directory structures without actually comparing the data in files? This works fine: diff -qr dir1 dir2_ But it's really slow because it's comparing files too. Is there a switch for diff or another…
Jonah
  • 955
62
votes
7 answers

How to print files that would have been changed using rsync?

Is there a way to get rsync to print the full filepaths to all files that are different without actually transferring any files? Alternatively, I need a way to diff the files across two trees (over SSH) based only on change in size or last-modified…
Joe Tsai
  • 629
59
votes
4 answers

vimdiff: Jump to next difference inside line?

vimdiff is very handy for comparing files. However, I often use it on files with long lines and relatively few differences inside the lines. vimdiff will correctly highlight differences inside a line (whole line pink, differing characters red). In…
sleske
  • 23,525
58
votes
1 answer

diff directories, excluding one folder inside

I think I have two directories with the same content, but I want to check it. Also, I want to exclude a folder that is inside both directories. How can I do it?
tirenweb
  • 1,391
56
votes
7 answers

How can I enable colored output for OSX diff?

I need to diff two files (not two versions of the same file, they are however tracked by git, but that is unrelated) and I would like some colored output, how can I achieve that? $ diff file_1 file_2 1,9d0 <