Questions tagged [diff]
diff is a shell command to find differences between two files. It is common on all *nix based systems
294
questions
474
votes
18
answers
866k
views
How do I compare binary files in Linux?
I need to compare two binary files and get the output in the form
<fileoffset-hex> <file1-byte-hex> <file2-byte-hex>
for every different byte. So if file1.bin is
00 90 00 11
in ...
113
votes
2
answers
47k
views
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/
110
votes
10
answers
106k
views
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 ...
83
votes
6
answers
71k
views
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?
67
votes
13
answers
64k
views
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 ...
60
votes
7
answers
91k
views
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 ...
56
votes
1
answer
51k
views
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?
56
votes
4
answers
45k
views
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 ...
54
votes
7
answers
30k
views
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
...
44
votes
6
answers
39k
views
How to diff large files on Linux
I'm getting a diff: memory exhausted error when trying to diff two 27 GB files that are largely similar on a Linux box with CentOS 5 and 4 GB of RAM. This is a known problem, it seems.
I would expect ...
42
votes
3
answers
39k
views
Listing lines from just one file in DIFF
I would like to get (GNU)DIFF to printout only lines that are different in one file.
So given
==> diffa.txt <==
line1
line2 - in a only
line3
line4 changed
line5
==&...
42
votes
4
answers
23k
views
Using diff on a long one line file
I have a file that has only one line. Its size is about 20,000 bytes.
The file has been modified, and I wanted to know where.
I thought using diff, but it shows me the complete line, because it ...
41
votes
5
answers
73k
views
How do I do a binary diff on two identically sized files under Linux?
I have two identically sized files, and I need to do a binary diff to check whether they're the same.
I'm currently runnnig diff file1.img file2.img but it's taking quite a while to process my 4 ...
39
votes
4
answers
36k
views
How to diff file names in two directories (without writing to intermediate files)?
I am trying to do something along the lines of:
diff `ls -1a ./dir1` `ls -1a ./dir2`
But that doesn't work for obvious reasons. Is there a better way of achieving this (in 1 line), than this?
ls -...
38
votes
11
answers
86k
views
How can I compare big files under Windows? [closed]
I'd like to compare two files under Windows, each about 1Gb in size. I tried Total Commander and WinMerge, but both ended with Out of memory errors.
I'm running Vista Home Premium 64bit with 8GB of ...
37
votes
4
answers
45k
views
How can I make 'diff -X' ignore specific paths and not file names?
Doing:
diff -r -X <ignore-list> <src-dir> <dest-dir>
doesn't seem to make diff ignore entries in <ignore-list> if they are of the form <dir>/<file>.
Entries of ...
34
votes
2
answers
26k
views
Can I replace internal diff in Total Commander with a custom tool?
Since I don't really like Total Commander's internal diff Compare Contents used in Compare by content and Synchronize Dirs → Compare left & right, I want to use something else like WinMerge or ...
32
votes
4
answers
20k
views
interactive/visual merge tool for console?
I'm a big fan of meld - a visual diff and merge tool for Gnome. It shows two files (or directories) side-by-side and with their differences highlighted, and I can easily select which parts I want to ...
32
votes
7
answers
36k
views
Prevent diff from checking for newline at end of file
I have two big trees, which I want to compare. Some of the files in the tree differ just because one has newline at the end, and the other file lacks this newline. I want to ignore this fact. I have ...
31
votes
1
answer
10k
views
Git: Performing a diff between two stashes
Is it possible with Git to perform a diff between two stashes?
For instance, I have the following stashes:
stash@{2}: On peformanceFix#3: 20170728T164841
stash@{3}: On peformanceFix#2: ...
30
votes
1
answer
12k
views
how can I tell vimdiff to ignore whitespace?
I made a number of changes in a file I'm working on, including indentation changes. I'm using vimdiff to compare the file to the original version, and I don't want to see these changes, since they're ...
28
votes
2
answers
39k
views
Diff -b and -w difference
From the diff manpage:
-b, --ignore-space-change
ignore changes in the amount of white space
-w, --ignore-all-space
ignore all white space
From this, I infer that the difference between ...
27
votes
2
answers
31k
views
How to diff only the first line of two files?
I want to diff only the first line of two files, as opposed to the entire file. How would I do that? I only need a solution for the the first line, but if you could specify the number of lines that ...
26
votes
5
answers
32k
views
Is there any free *.diff file viewer? [closed]
Is there any free software that will run on Windows 7 to show syntax highlighting for *.diff files generated from comparing files? I don't want to compare files, just view the highlighted output from ...
24
votes
6
answers
28k
views
Alternative for WinMerge in Ubuntu
I need to compare/diff/merge files in an easy way. In windows I would use WinMerge. What alternatives for this are available in Ubuntu?
The things I must be able to do:
See 2 files line by line next ...
24
votes
4
answers
12k
views
Windows Explorer - Diff two files from the context menu?
Is there any way to diff two selected files from the context menu in Windows Explorer?
23
votes
4
answers
23k
views
Binary diff/patch for large files on linux?
I've got two partition images (A and B) and want to use them to create a patch that I can apply on A on another computer in order to get the new B image without flooding the network. I have the ...
22
votes
2
answers
15k
views
Get recursive list of different files in Winmerge (without folder tree/structure)
I prefer Winmerge to Diffmerge, but the one thing I envy is Diffmerge's folder diff feature.
Diffmerge shows, for complicated folders and subfolders, only different files (not folders).
Winmerge ...
20
votes
3
answers
13k
views
How to Use WinMerge as the Diff tool for Mercurial
I'm using the Mercurial distributed version control system, and I'm wondering how I can configure it to use WinMerge instead of its own internal diff tool. I've already got WinMerge as the merge tool,...
20
votes
4
answers
14k
views
How to ignore moved lines in a diff
I am currently working on a source code generation tool. To make sure that my changes do no introduce any new bugs, a diff between the output of the program before and after my changes would ...
19
votes
4
answers
12k
views
Similarity and/or Diff of two ODT documents (Linux)
I have two ODT documents, they have very close contents, I want to compare them to see how similar they are.
The best would be to have a similarity percentage, if not possible, an alternative would ...
18
votes
5
answers
13k
views
Is there a way to access files from one WSL 2 distro/image in another one?
I have several Unbuntu WSL 2 "installations" on my Windows 10 system and I'd like to be able to run tools like rsync and diff between them. Is it possible to mount/find where the files for ...
18
votes
6
answers
17k
views
Difference in whitespace between two files on Linux
I have two files that when I compare with diff show that every line has changed. When I compare them with diff -w (ignoring whitespace) it shows the few minimal changes that I expect.
Obviously ...
17
votes
4
answers
22k
views
How to diff directories for different files, but not line-by-line
I want to see, recursively, files that are different in two directories. Diff can do this, but it shows me the line-by-line differences, which I don't want. Is there a tool that does this, or a way to ...
17
votes
2
answers
4k
views
Is there any way to find similar files (not duplicates)?
My final goal is refactoring code written by my coworkers. So, is there a tool which can find files differing in only few words?
(Edit: this is for a Mac, but others might like non-Mac answers too.)
16
votes
2
answers
9k
views
Is it possible to have meld open all files at once when used with "git difftool"?
Meld is capable of loading many files at once (in tabs).
However when used with git difftool, Git will ask if you want to view each file (which can be slow and annoying to have to keep opening and ...
15
votes
5
answers
16k
views
compare two directory trees
I have two music libraries, one a newer version than the other. I would like to compare them to figure which files I need to copy from new music tree to old.
I have tried diff --brief -r /...
14
votes
1
answer
10k
views
How do you get Eclipse's built-in diff tool to ignore differences in whitespace?
I'm working on a large codebase that's been touched by many hands. As I work through bugs, I've been converting the source to be more readable which involves a lot of minor changes in indentation ...
14
votes
6
answers
1k
views
Line-length-tolerant XML diff
I've looked at the answers to this question, and unfortunately none of them has helped me so far.
Not to beat about the bush, the second edition of C# in Depth is now in copy edit. I want to be able ...
13
votes
4
answers
13k
views
Is there a tool to measure file difference percentage?
I am looking to compare two text files. Normally, I can just use diff to compare the two files to see the differences. This is great, except that I am more concerned with the percentage difference of ...
12
votes
3
answers
31k
views
How do I compare two folders recursively and generate a list of files and folders that are different?
tl;dr and an example
I'm looking for a way to compare two folders recursively and output the relative paths all files (and folders) that are different (by size or by timestamp, à la rsync).
For ...
12
votes
4
answers
9k
views
Tool for comparing a single line of text
Is there a tool for comparing two lines of text?
All the tools I have compare on a line level, when I really need a character level diff in the line.
Windows or *nix, GUI or command line, I don't ...
11
votes
3
answers
2k
views
How to ignore whitespace in Kaleidoscope (diff tool)?
In Kaleidoscope, how do I configure it to ignore whitespaces?
11
votes
5
answers
16k
views
How can I compare two directories, one being a remote directory?
I want to compare two directories, one is local and the other is on another machine.
How can I do that? Can I do it with diff?
11
votes
2
answers
14k
views
How can I diff two network dumps from tcpdump or Wireshark?
I'm having a problem with one of our customers' embedded computers. They seem to discard some network packets which they should not. I can capture the TCP communication from a managed switch outside ...
10
votes
3
answers
5k
views
Is there any graphical display tool for diff output?
I would like to post-process diff output and then pass the results to a graphical viewer, such as kdiff3 or xxdiff. If possible, I would like to be able to highlight in-line differences using ...
10
votes
1
answer
13k
views
Sorting XML files so that differences can then be found
I need to compare two XML files, each of which is about 13,000 lines long.
Sadly the code that generates these files doesn't generate the data in the same order each time (the data comes from a ...
9
votes
2
answers
5k
views
Use Meld instead of Kompare in KdeSVN
i tried using Meld as external diff in KdeSVN as meld -on - (settings>configure kdesvn>diff&merge) but Meld complains that the usage is wrong:
meld: error: no such option: -o
Finished
Usage:
...
9
votes
3
answers
4k
views
View incremental diffs of my revisions to files using Dropbox
Sometimes I use a simple editor like Notepad++ to edit my webpages on Dropbox.
Notepad++, not being an über-editor or IDE, does not track file changes for me.
But Dropbox does!!
Has anybody ...
9
votes
2
answers
12k
views
git diff --no-index but with multiple files
I really like git diff's output format, and I use it a lot as git diff --no-index to compare arbitrary non-git-related files. But as far as I can tell when using --no-index you can provide only a ...