Questions tagged [diff]

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

526 questions
196
votes
5 answers

Understanding 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: diff file1.txt file2.txt I get: 3d2 < line3 5a5 >…
Jim
  • 9,750
  • 15
  • 57
  • 84
172
votes
15 answers

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 list of comma-separated values are actually the ones…
user394
  • 14,194
  • 21
  • 66
  • 93
161
votes
1 answer

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 or j; { or }; Up or down arrow keys (select more…
Alex Leach
  • 7,720
  • 4
  • 28
  • 27
111
votes
4 answers

Can't pipe into diff?

I wanted to be clever and compare a remote file to a local file without first manually downloading it. I can get the contents of the remote file by ssh user@remote-host "cat path/file.name" However, piping that to diff ssh user@remote-host "cat…
user394
  • 14,194
  • 21
  • 66
  • 93
88
votes
5 answers

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 commands, but this is not what I'm after. It would…
Zaid
  • 10,442
  • 13
  • 38
  • 36
79
votes
15 answers

How to color diff output?

I wanted to format the Unix files conditionally, I am currently working on diff command and wanted to know if it is possible to format the text of the diff command output. Example: Matched values should be displayed in green. Unmatched values…
Aman
  • 1,151
  • 2
  • 11
  • 17
78
votes
10 answers

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 program into coloured html file? Other output…
Grzegorz Wierzowiecki
  • 13,865
  • 23
  • 89
  • 137
66
votes
6 answers

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 files, skipping the comments? A commented line is…
Lekensteyn
  • 20,173
  • 18
  • 71
  • 111
65
votes
3 answers

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 pointing to the same, non-existing targets). diff then outputs error…
Marcus Junius Brutus
  • 4,427
  • 11
  • 43
  • 63
59
votes
6 answers

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 see the detailed differences, but it makes manual…
Lekensteyn
  • 20,173
  • 18
  • 71
  • 111
53
votes
5 answers

Run a diff between local and remote files

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 an another host, also accessible via ssh, without having to manually download the remote file first before running the…
fduff
  • 4,925
  • 4
  • 35
  • 39
50
votes
1 answer

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 126 character width, which is not even half of my…
VxJasonxV
  • 1,507
  • 2
  • 11
  • 12
49
votes
4 answers

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.
Jonas Lejon
  • 679
  • 1
  • 6
  • 10
48
votes
2 answers

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)
KALAI SELVAN
  • 811
  • 2
  • 10
  • 11
47
votes
7 answers

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 same. The output from diff is the whole 2…
MinaHany
  • 735
  • 2
  • 6
  • 10
1
2 3
35 36