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

learn more… | top users | synonyms

3
votes
3answers
271 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
4answers
643 views

Can I get the opposite of `diff -q` — matching identical files without printing their contents

I have a number of files in a directory, and I want to check that they are all unique. For simplicity, let's say I have three files: foo.txt, bar.txt and baz.txt. If I run this loop, I will check them ...
3
votes
1answer
74 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 ...
3
votes
1answer
77 views

How to create a patch ignoring indentation differences in the code?

I'm trying to create patch a file using diff tool.But facing an issues.The way I am doing is below. I've created one Directory named a and put original file in to it. a/original_file.c Now I have ...
3
votes
3answers
1k views

Get correct number of lines in diff output

I want to get the correct number of lines in the output of diff(specifically with -y and --suppress-common-lines options). Using a simple wc -l does not work, because if both files end without a ...
3
votes
1answer
61 views

How do I diff the outputs of two commands?

How can I use the diff command to compare 2 commands' outputs? Does something like this exist? diff ($cat /etc/passwd) ($cut -f2/etc/passwd)
3
votes
2answers
88 views

Comparing files in unix columnwise

I want to compare two files with same number of rows and columns with records in same order. Just want to highlight the differences in the column values if any. file A: 1,kolkata,19,ab ...
3
votes
3answers
339 views

How to diff two folders by inodes

I'm currently using a script to backup files on my computer. In a nutshell, it works like this: rsync --link-dest=$FOLDER/current $SOURCE $DESTINATION However, I think that my script may be ...
3
votes
2answers
2k views

how to include a new file into a patch

I try to make a patch as introduced here. Say I have two directories pp1(modified version) and pp0(clean version), I make a patch file pp0.patch with the diff command: diff -crB pp0 pp1 > ...
3
votes
1answer
3k views

What does 'patch unexpectedly ends in middle of line' mean?

This is the output of my patch command: Hunk #11 merged at 4184,4190. Hunk #12 merged at 4444. Hunk #13 merged at 4944. Hunk #14 NOT MERGED at 5106-5116. Hunk #15 merged at 5290. Hunk #16 merged at ...
3
votes
1answer
414 views

How to pipe diff into Kompare?

I want to quickly compare files in two different directories to see if the files are the same (same content). I want to see the results in Kompare (I'm on KDE - Kubuntu 12.04). Here's my diff ...
3
votes
1answer
85 views

How-to diff distributions?

I am using a Raspberry Pi. There seem to be all kinds of linux distributions, all in .img Format that I use Win32DiskImager for to burn to SD-card. How do I find out, which files were changed(some ...
3
votes
1answer
32 views

git diff of copies that only added lines

Say I have two processes that append lines to copies of the same original (parent) file (copy_A and copy_B). If I diff these copies, can diff ever conclude that we have a conflict? (i.e. can it ever ...
3
votes
2answers
2k views

Difference of folders and files

I have two folders which have different folders inside. Those folders also contains different files. I am looking for the command that would give me the difference between those two parent folders. ...
3
votes
3answers
235 views

Track daily directory changes (and email them)

I have a Debian powered NAS server (ReadyNAS) with a deep file hierarchy. I'd like to get notified daily about what has changed in some of its directories and their subdirectories. So if someone ...
2
votes
1answer
1k views

Diff the output of two `awk` commands

I'm trying to compute the difference between the output of two awk commands but my simple attempts at it seem to be failing. Here is what I'm trying: diff $(awk '{print $3}' f1.txt | sort -u) $(awk ...
2
votes
2answers
203 views

How to determine if file is just a permutation of another one?

Consider for example a source code file, where the functions are drastically shuffled around. Is there is a command to check if the reordering of lines is the only change? (that means no lines are ...
2
votes
3answers
1k views

Comparing text files using Bash and AWK

I have two text files, and I want to compare their corresponding values according to their rows and columns. By comparing, I mean to check if the values are equal and echo if the values are the same ...
2
votes
1answer
116 views

diff --git unknown option

when I try to run diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c I get unknown option (I have installed git via apt-get install git)
2
votes
2answers
81 views

How can I show the number of positions lines have moved in diff output?

top1 1,facebook.com 2,google.com 3,youtube.com 4,yahoo.com 5,wikipedia.org 6,baidu.com 7,live.com 8,amazon.com 9,qq.com 10,twitter.com top2 1,facebook.com 2,google.com 3,youtube.com 4,yahoo.com ...
2
votes
3answers
45 views

Is cmp faster than diff -q?

In a recent AU question on checking whether some files have differing content, I saw a comment stating that if the differing sections didn't matter, cmp would be faster than diff. This SO answer ...
2
votes
3answers
445 views

Diff 2 files ignoring strings between @ and [

I am comparing two files. I am trying to ignore the alphanumeric characters after @ and before [ . A line looks like model.Field@d6b0d6b[fieldName
2
votes
2answers
2k views

Diff, show modified line from right file only

I have file a and b and I would like to output lines of b that changed since it was cloned from a. Just the modified lines, no surrounding context, no diff offset marks. How can I do that using shell ...
2
votes
2answers
61 views

How can I compare two files based on the value of the first column?

I want to compare two files based on the value of their first column: file1 aaa 23 3 bbb 56 6 ccc 45 2 file2 bbb m a aaa a m ccc m m The output file should be: aaa a m bbb m a ccc m m ...
2
votes
1answer
36 views

How can we compare two same directories in linux and list different files

Suppose I have same version of linux kernel but I changed some driver lines. Is there any way to compare these kernels and list the results. The result would be helpful to go back if I changed a lot ...
2
votes
2answers
205 views

Understaning of diff output

I have file1.txt this is the original text line2 line3 line4 happy hacking ! and file2.txt this is the original text line2 line4 happy hacking ! GNU is not UNIX if I do: ...
2
votes
2answers
2k views

How do I pipe colored diff output to less?

I've been using git diff, which produces colored output. However, I now find I need to use ordinary diff for something, and it's producing a lot of output that is hard to read because of the lack of ...
2
votes
2answers
160 views

Live diff-mode editing in vim

I want a live view of diffs while I am editing a file. vimdiff is able to do something I want, like highlighting the differences between two files. However there are two drawbacks of vimdiff that ...
2
votes
2answers
66 views

Keep patch in sync with changing source

Is there any standard option to create 'patch' P that works on file F in such way that it will keep working correctly when file F changes into F'. So I will either have some mechanism that will ...
2
votes
2answers
120 views

Using Diff with -y to get side-by-side output

I am trying to use diff with -y to get side-by-side output, but my output gets messed up after about 18 lines. Here is an example, any clue why? (Check from *.java_pool_size=134217728) : ...
2
votes
1answer
111 views

Is there a way to define the preferred merge or diff tool under Unix?

I know that you can define the preferred editor by setting the EDITOR environment variable. My question is if there is a similar solution for setting the preferred merge or diff tool.
2
votes
1answer
2k views

Patching a file (in this case dwm) and failed hunks

I'm trying to add the transparency patch to dwm. I downloaded the .diff file and in my dwm directory ran this: max@linux-vwzy:~/misc/dwm/dwm-5.9> patch < dwm-transparency.diff patching file ...
2
votes
2answers
494 views

Comparing files and their properties

I get information of a certain set of files in my mail every day, which looks like this: 58623208 Sep 14 20:08 blbn_blfbe_drv 57904920 Sep 14 19:54 blbn_cycmn 55814208 Sep 14 06:02 clsa_Upd 38912000 ...
2
votes
3answers
1k views

Total Commander “compare content” like alternative?

I'm searching a GUI [or CLI] tool that can produce output like the Total Commander compare content function does! For example: Are there any that do that? It's a very handy tool and I miss it
2
votes
3answers
1k views

Alternative to diff with progress for massive directory compare?

I just rsync-ed 2,000,000 files (3TB) from one RAID to another. I want to make sure my data is intact. rsync -c takes a really long time. diff doesn't show me what it's doing. Is there an ...
2
votes
2answers
41 views

Diff dpkg files with local copies

Is there a way of diffing the dpkg files with the one that are actually installed? Or barring that a way to find ones that have been modified?
2
votes
2answers
53 views

How to show names of files being compared?

I used diff --from-file to compare my Riak dev1 config to the three others. diff --from-file ~/riak/dev/dev1/etc/app.config \ ~/riak/dev/dev2/etc/app.config \ ~/riak/dev/dev3/etc/app.config \ ...
2
votes
3answers
99 views

Hot to make diff check a symlink link itself?

In Linux one can use the command diff to check for differences of files. I use it to check for differences across two modules, both copied to /tmp. However, both modules have symlinks, which might ...
2
votes
4answers
1k views

Check whether two directories and their subdirectories are the same

With diff -r I can do this task, however it takes so long because diff checks file's content. I want something that determine that two files are the same regarding of their size, last modified, etc. ...
2
votes
1answer
259 views

password problem when feeding a remote file into diff

When I want to compare a local file with a remote file, any of these usually works: $ ssh remote cat file | diff file - $ diff file <(ssh remote cat file) However, sometimes (especially when the ...
2
votes
1answer
71 views

diff two directories for changes and format output to use for script

I currently try to monitor two directories and subdirectories for changes in files. The directories contain the same set of files, some of them are changed. So I thought I might use the diff command ...
2
votes
1answer
603 views

How to compare two tar archives (including file content, new/removed files, symlinks)?

I have two tar archives (compressed or not compressed), and I want to find all differences in the two archives. Both archives contain a complete file system (i.e. when unpacked, would generate ...
2
votes
1answer
294 views

Compare all text files in a directory, and sort by similarity

In Unix, is there any way to compare every text file in a directory to every other text file in the directory, and then sort each pair of files by similarity (using the diff utility)? There are ...
2
votes
0answers
46 views

One way diff between 2 directories

I am looking to perform a diff between 2 directories, both of which contain may files and subdirectories. I am hoping to perform a one-way diff between a source and target directory that will return ...
2
votes
0answers
174 views

diff -r only for certain file types

Is there a way I can perform a recursive diff of two directories but only compare (in their respective places) files that match a specific filename or filetype predicate? E.g. I would like to do ...
2
votes
1answer
233 views

How can I see moved lines in a file comparison with vimdiff / diff?

Moved lines are frequently annotated as deletes and adds but they can be shown as moved-from and moved-to instead. Like in this screenshot of Notepad++.
2
votes
2answers
153 views

Getting diff (or git diff) to show inserted hunks properly

Let's say I have two files. The first one has the contents: line 1 foo line 2 line 1 bar line 2 And the second one has a new section inserted in the middle, so it looks like this: line 1 foo ...
2
votes
0answers
152 views

Using Unison with colordiff

I want Unison to show the diffs with colordiff. I’ve got diff = colordiff -u CURRENT2 CURRENT1 | less -R in my config file but it seems like Unison pipes the output to plain less nonetheless, so I ...
1
vote
2answers
78 views

Possible to view two text files side by side (read only)?

In emacs, we can view two text files side by side. Is it also possible to do so in some simpler/lighter applications such as less? Only viewing, no editing.
1
vote
1answer
634 views

Pipe diff file into patch?

Is there a way to pipe the diff output into patch? The -i parameter is for specifying a diff file, but I just want to do it more dynamically, since I will be updating regularly against a directory ...