diff - Command-line tool to display the differences between two files, or each corresponding file in two directories.

learn more… | top users | synonyms

19
votes
4answers
7k views

Can't pipe into diff?

I wanted to be clever and compare a remote file to a local file without downloading it. I can get the contents of the remote file by ssh user@remote-host "cat path/file.name" However, piping that ...
18
votes
1answer
4k views

What's the recommended way of copying changes with vimdiff?

When comparing files, and updating a source code repository, I like to use vimdiff. To copy changes made from one file to the other, I usually use a key sequence like this:- Shift + V (select line) k ...
16
votes
3answers
11k views

How to diff files ignoring comments (lines starting with #)?

I've two configuration files, the original from the package manager and a customized one modified by myself. I've added some comments to describe behavior. How can I run diff on the configuration ...
15
votes
3answers
12k views

Comparing two files in Vim

Is it possible to view two files side-by-side in Vim? If so, how can I set up my editor to do this, and is there a way to diff between the two files within Vim? I am aware of the :next and :prev ...
15
votes
7answers
19k views

Which GUI diff viewer would you recommend?

I've hardly ever used anything other than Meld. Can you recommend anything else? It would be extra nice if you give a reason for your recommendation (as a Comment). [note] I want an alternative ...
13
votes
7answers
6k views

diff within a line

I have some sql dumps that I am looking at the differences between. diff can obviously show me the difference between two lines, but I'm driving myself nuts trying to find which values in the long ...
12
votes
4answers
3k views

Converting colored output into html

There are tools providing coloured output: dwdiff -c File1 File2 # word level diff grep --color=always # we all know this guy ... The question is: How to convert their colored output of arbitrary ...
10
votes
4answers
426 views

rolling diffs for storage of highly similar files?

At work we do a nightly dump of our mysql databases. From day to day, I would guestimate that close to 90-95% of the data is duplicate, increasing as time goes on. ( Heck at this point some are ...
10
votes
2answers
1k views

Is there a condensed side-by-side diff format?

I have two log files with thousands of lines. After pre-processing, only some lines differ. These remaining lines are either real differences, or shuffled groups of lines. Unified diffs allow me to ...
10
votes
2answers
310 views

Is there a Linux deep diff tool that also compares file attributes?

Is there a Linux tool like diff that will recursively compare files and directories, but with the addition of also comparing: extended attributes, acl's, se contexts?
9
votes
5answers
275 views

Diff head of files

I have two files. One file, I suspect, is a subset of the other. Is there a way to diff the files to identify (in a succinct manner) where in the first file the second file fits?
8
votes
4answers
2k views

diff reports two files differ, although they are the same!

I have two files which look identical to me (including trailing whitespaces and newlines) but diff still says they differ. Even when I do a diff -y side by side comparison the lines look exactly the ...
8
votes
5answers
8k views

Output the common lines (similarities) of two text files (the opposite of diff)?

Diff is a great tool to display the changes between two files. But how to display the similarities of two text files (while ignoring the differences)? I.e. sample input: a: Foo Bar X Hello World 42 ...
7
votes
7answers
326 views

Review changes in .tex files

I have two files paper.tex and paper_suggested_changes.tex the latter is a modified version of the former with corrections. I need to go through the two files and choose which changes to accept or ...
7
votes
3answers
449 views

Run a diff between local and remote file

I'm connected on a host via ssh and I'd like to compare (let's say with diff) a certain config file against its counterpart on another host, also accessible via ssh, without having to manually ...
7
votes
9answers
4k views

linux diff tools: create list of modified files

How do I create a list of modified files programmatically using linux command line tools? I'm not interested in the difference in any particular file (delta, patch). I just want to have a list of new ...
7
votes
4answers
619 views

How can I get the most bang for my buck with the “diff” command?

I have tried using the linux diff command in the past without much luck or patience. I usually end up using a GUI utility like DiffMerge or Kdiff. Recently I started trying to use diff again to ...
7
votes
1answer
5k views

diff - output line-numbers

I want to use cli tool for file comparison and need line-number before output line with which help I could jump to line difference, because I use tool which understands where to jump, if the line ...
7
votes
3answers
183 views

How do I compare a file with a floppy image and the actual floppy's content?

Is there a command that compares a floppy disk image (e.g. a .iso file) to the actual contents of the floppy the image was written on (e.g. /dev/fd0)?
6
votes
2answers
2k views

diff where lines are mostly the same but out of order?

I want to diff two sets of mod_rewrite rules. The set of lines are about 90% identical, but the order is so different that diff basically says they are completely different. How can I see which lines ...
6
votes
2answers
5k views

Diffing two big text files

I have two big files (6GB each). They are unsorted, with linefeeds (\n) as separators. How can I diff them? It should take under 24h.
6
votes
2answers
3k views

How do I save changed files?

I have two folders: ORIGINAL/ ORIGINAL_AND_MY_CHANGES/ My friend has a copy of ORIGINAL/. I would like to generate MY_CHANGES.tgz -- it should contain only new/changed files from ...
6
votes
1answer
647 views

Is there bdiff (1) in Linux?

There is bdiff(1) command in Solaris, which allow you to diff(1) files with size bigger than your RAM size (http://docs.oracle.com/cd/E19683-01/806-7612/files-23/index.html). Is there something like ...
6
votes
2answers
536 views

Same file, different filename due to encoding problem?

I was about to diff a backup from it's source to manually verify that the data is correct. Some chars, like åäö, is not shown correctly on the original data but as the clients (over samba) interpret ...
6
votes
1answer
1k views

Comparing directories in Emacs

I am experimenting with ediff-directories, but I am not sure I am using it correctly. I read in the documentation that, once I supply two directories to ediff-directories, if I press == Emacs ...
5
votes
6answers
3k views

Compare files that are in directory 1 but not directory 2?

I'm having trouble with a bash script I want to make I know ls will list files that are in a directory but I want it to list directories that are in directory1 but NOT in directory2, and then list ...
5
votes
1answer
2k views

Make diff Use Full Terminal Width in Side-by-Side Mode

Most applications are smart about using the full width of the terminal available to them. My shell does, screen, vim, etc. However, diff in side-by-side mode (-y), does not. This angers me. It uses ...
5
votes
4answers
847 views

Compare an old file and new file, but ignore lines which only exist in new file?

I have two files: oldlist - This contains a list of files and a md5 hash for each file. This was generated one year ago. newlist - This also contains a list of files and a md5 hash for each file. ...
5
votes
3answers
3k views

How do I “merge” two text files?

I recently upgraded from Ubuntu 12.04 to 12.10 and at one point, it encountered an Apache config file conflict in apache2.conf. I didn't give me a merge option at that point, so I just rejected the ...
5
votes
1answer
666 views

Comparing text files on Emacs

I have a couple of questions about comparing text files on Emacs I have been playing with M-x compare-windows and I read in the documentation that, if I pass it a numeric argument, Emacs ignores ...
5
votes
3answers
2k views

How do you compare two folders and copy the difference to a third folder?

You've got three folders: folder current, which contains your current files folder old, which contains an older version of the same files folder difference, which is just an empty folder How do ...
5
votes
1answer
297 views

merge that works at word granularity instead of line

The old diff, patch, and merge programs, and their modern descendents in the form of version control systems work great for managing source code that can be edited concurrently by multiple people. ...
4
votes
4answers
971 views

Error with if [ -n $diffCurr ]: Too many arguments

I have been using the below code ok for sometime, but now, I get an error java Editor < "input/editor$i.in" > "tmp/editor$i.out" diffCurr="$(diff "tmp/editor$i.out" "output/editor$i.out")" if [ ...
4
votes
4answers
3k views

Diff several files, true if all not equal

I have a number of files, I want to check that all those files have the same content. What command line could I use to check that? Usage could be something like: $ diffseveral file1 file2 file3 ...
4
votes
1answer
51 views

Compare files and tell how similar they are

Is there a way to compare two file and give some kind of numeric indication of their similarity? For example, if I have two files that differ by just one character (say, a character was deleted or ...
4
votes
1answer
104 views

In Emacs, how do I inspect what has been modified in a buffer (before saving and overwriting the file)?

In Emacs, how do I inspect what has been modified in a buffer (before saving and overwriting the file)? (In a sense, the requested action is an analog of git status and git add -i showing what has ...
4
votes
3answers
5k views

Recursively compare two directories with diff -r without output on broken links

I am using diff -r a b to recursively compare directories a and b. It often happens though that there are some broken links (the same broken links in both a and b directories and to the same, ...
4
votes
1answer
150 views

Why does diff fail when invoked from a Makefile?

Narrow-down of a patch problem I am trying to troubleshoot: Only two files, each with a size of 1 byte: file a (containing 'a') file b (containing 'b') and Goal is to make and then apply a patch ...
4
votes
2answers
811 views

Get diff changes between original files installed with apt and current files

I installed php5-fpm package using apt; then I made some changes to the PHP configuration files. Now I would get the diffs between the original files versions (the ones of the package installed) and ...
4
votes
1answer
56 views

heuristically find how different a set of files are

I am having a large number of output files produced by repeated runs of a test suite and would like to see, approximately, how different they are. Ideally they should all be identical (indicating a ...
4
votes
6answers
2k views

how to use patch and diff to merge two files

I have read about diff and patch but I can't figure out how to apply what I need. I guess its pretty simple, so to show my problem take these two files: a.xml <resources> <color ...
4
votes
2answers
764 views

diff a gzipped tarball against a directory?

Is there a way I can diff a gzipped tarball against an existing directory? I would like to be able to do it without extracting the data from the tarball.
4
votes
1answer
2k views

Recursively compare directory contents by name, ignoring file extensions

I have a directory containing about 7,000 music files. I used lame to recursively re-encode all files in it to a separate directory, outputting all files with the same relative path and file name. ...
4
votes
2answers
274 views

How to know if a text file is a subset of another

I am trying to find a way to predict if a text file is a subset of another.. For example: foo bar is a subset of foo bar pluto While: foo pluto and foo bar are not one a subset of each ...
4
votes
3answers
168 views

Smart way to perform a similar replacement (not simple enough for diff) in multiple files?

I have a bunch of files (45, so too many to edit them manually without going crazy) which all require the same changes (as seen in the three diffs at the end of this question). Most tools used for ...
4
votes
1answer
408 views

How to use diff tool to take a diff between directories with libraries and source?

I would like to know if i can use the diff tool to take the difference between two folders which contain sources as well as libraries and executable. Right now i gave diff -Naur dir1/ dir2/ ...
3
votes
4answers
499 views

On Unix how do I get the output from the diff command to look like a man page? Where I can press 'b' or 'f' to read further or back?

You know how when you use the man command to read the manual (e.g. man ls) and you get output that is paginated that you can read from top to bottom by pressing 'f' to go read further down and 'b' to ...
3
votes
5answers
285 views

Kompare-like tool that needs no kdelibs dependencies?

Are there any Kompare-like tools without KDE dependencies? Can be Qt or GTK based.
3
votes
3answers
261 views

How to make and apply (patch) one side diff?

I want to make a shell script that updates a config file. The file present on the server has information, like various IP addresses. The new file has more code, from new configs added to the system, ...
3
votes
1answer
62 views

Compare two files strictly line-by-line, without insertions or deletions

I have two files that essentially contain a memory dumps in a hex format. At the moment I use diff to see if the files are different and where the differences are. However, this can be misleading when ...