Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [diff]

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

1
vote
1answer
26 views

show does diff --exclude work?

I'm trying to use diff to compare two directory trees while ignoring certain sub-directories, but I'm not able to get it to work. This is what my file structures looks like: temp/ |-- d1/ |-- f1....
2
votes
1answer
50 views

bash remove common lines from two files

I have two files, (no blank lines/Spaces/Tabs) /tmp/all aa bb cc hello SearchText.json xyz.txt /tmp/required SearchText.json and the end output I want is : (all uncommon lines from /...
-2
votes
2answers
63 views

Script not correctly printing the correct elements of the array

So basically I have to write a bash script that examines some specific files from the working directory (which are named file.00.txt up to file.24.txt). The thing is, 3 of them are exatcly the same ...
1
vote
2answers
49 views

Compare every nth line in 2 files and save (asymmetric) context

I have 2 files, each containing the same amount of 4-lines records, in the same order: fileA: record1 line1=header record1 line2 X <= this is different but should be ignored record1 line3 id ABC ...
0
votes
1answer
31 views

linux + compare between two folders

under /usr/lib/ambari-metrics-get folder and /usr/lib/ambari-metrics-put we have jar files /usr/lib/ambari-metrics-get/stax-api-1.0.1.jar /usr/lib/ambari-metrics-get/stringtemplate-3.2.1.jar /usr/...
0
votes
1answer
30 views

use 'diff-highlight' for diff

I have set up diff-highlight as pager / highlighter for git. [pager] log = diff-highlight | less show = diff-highlight | less diff = diff-highlight | less That works perfectly. But how ...
5
votes
1answer
74 views

Command-line diff tool

So we all have the diff command installed by default. I certainly don't know how to use it well. But I would expect some reasonable default usage. But when I type diff file1 file2 I get ... a text ... ...
0
votes
3answers
35 views

How to tell the difference between changed and added lines?

I have two csv files where I want to figure out the deleted, modified and added lines. (The first field is an unique id.) The first file looks like: 0, WILL_BE_REMOVED 1, OLD 2, SAME 3, SAME and a ...
0
votes
2answers
47 views

How can I compare two files by using just two columns and print the difference (without sorting)?

I have two files: File 1: No ID CV CA1 CA2 1 transcr_10283 0.999023367236861 -0.344113101336184 -0.032235130455987 2 transcr_10371 -0.572755303094372 -0.579145581184253 0....
2
votes
1answer
137 views

How to generate (git) diffs with <n> characters of context?

The --unified=<n> option lets you set the number of lines; is there a way to do the same for characters? example limit the context around the changes to X character(s) when using git diff --...
8
votes
1answer
450 views

diff showing only differences inside line

I want to compare lines in two files, but to minimize noise in the output, I want only the actual differences in the lines to be printed. For instance, given the two files below: a.txt a b c d e f ...
0
votes
0answers
18 views

Patch files with only additive changes

How can I use eg diff to create a patch file containing only the additive changes from file A to file B? Lets say B is a buffer containing only recent data, old data is deleted in a fifo manner. I ...
1
vote
1answer
75 views

Linux diff command, is it discarding newlines?

Does the Linux implementation if diff -w discard \n? I don't have access to a Linux machine to check that out.
1
vote
2answers
141 views

Diff between two csv files based on the column

I have two files file1.csv and file2.csv. Below are the contents of file1.csv AL.jar;d8c06ebedd7954681f34ab5c94fdc4fb AR.jar;9a553dd203d0979aa60004e19cc98c12 BI.jar;8022f6c5f83ba040394ff0b0a0323e8e ...
-1
votes
1answer
41 views

Linux Compare two files on different field and print field 1 of first file

I have two files like this. file 1 1:apple 2:banana 3:pineapple 4:guava 5:orange and file 2 like this apple guava orange i just want to compare file 2 with file 1 and print the 1st field for the ...
0
votes
2answers
44 views

How do I diff the output of these two commands? [duplicate]

I have an alias which I use to strip out comments that are piped to it: alias decomment='egrep -v "(^#.*|^$)"' I'm currently having some difficulty with a squid proxy setup, so I want to compare ...
2
votes
1answer
98 views

Multi-threading diff

I'm comparing the content of two directories using the diff command in bash. It uses only one thread on a multi-thread system. Does somebody knows a way to have diff to use more than one cpu/thread? ...
-1
votes
1answer
75 views

Find unique lines, ignoring certain columns

I want to be able to go through a file and find lines that are different in the fields I expect to be stable, ignoring differences in the fields I know will be different. I want to ignore columns 2,5,...
1
vote
1answer
40 views

How to see which files are identical given a list of files in two projects

I have two projects named project1 and project2 with identical file trees as follows. project1/, project2/ . ├── src │ ├── index.html │ ├── main.js │ ├── normalize.js │ ├── routes │ │ ├──...
1
vote
0answers
30 views

How shall I understand the different outputs by `-A` and by `-e` of diff3?

diffutils' manual says, in diff3 -A mine older yours The ‘--show-all’ (‘-A’) option acts like the ‘-e’ option, except that it brackets conflicts, and it outputs all changes from older to yours, not ...
-2
votes
1answer
72 views

How does `diff` decide whether a difference is change (i.e. replacement) or combination of addition and deletion?

I was wondering how diff decides whether a difference is change (i.e. replacement) or combination of addition and deletion? The best I can find from diffutils' manual is ‘fct’ Replace the ...
0
votes
2answers
40 views

How shall I understand the conditions for merging by diff3 to be well-defined?

In diffutils' manual diff3 mine older yours You can remember the order of the arguments by noting that they are in alphabetical order. You can think of this as subtracting older from ...
-3
votes
2answers
89 views

What do comm and diff try to accomplish at input/output level?

Given two files, for each line in each file, how do comm and diff determine whether the line also occur in the other file? if it does, whether its occurrences in the two files are the same or ...
0
votes
1answer
229 views

How shall I understand the unified format of diff output?

From diffutils' manual Next come one or more hunks of diff erences; each hunk shows one area where the files differ. Unified format hunks look like this: @@ from-file-line-numbers to-file-line-...
0
votes
2answers
366 views

Is there some tool for finding files in one directory but not in the other? [duplicate]

I would like to write a bash script to find those files in a directory but not in another directory. Does the following script work? When does it not? for i in "$1"/*; do f=$(basename $i); ...
0
votes
1answer
40 views

Can someone explain to me what this **diff** means..? [duplicate]

I'm having an extremely hard time to read this can someone explain what it means, and what the difference between the two is ? $> diff -U 3 user_output_test1 test1.output | cat -e --- ...
1
vote
3answers
88 views

How to ignore differences between negative signs of numbers in the diff command?

I have two large files consisting mainly of numbers in matrix form, and I'd like to use diff (or similar command) to compare these files and determine which numbers are different. Unfortunately, ...
22
votes
1answer
965 views

What effect does the “-d” option have with diff?

The diff implementation on OpenBSD has a non-standard -d option with the following documentation: -d Try very hard to produce a diff as small as possible. This may consume a ...
3
votes
2answers
183 views

How to produce a diff without lone identical lines

Let's say I have rewritten a C function from scratch. It often happens that some lines happen to be identical before and after, in particular blank lines and closing braces. When I create a unified ...
0
votes
1answer
28 views

Comparing IP info between two files based on criteria and outputting the results to two different files [duplicate]

I have a file called "knownIP". This file contain known IP addresses for a group of windows servers. These IP addresses are unique to this group of windows servers. I have another file called "...
0
votes
1answer
210 views

Diff outputs “binary files <file1> <file2> differ” but not the usual detail output

I would like to compare two files - "orienv" and "currenv", using the command diff. The way I had created the two files was as follow: Createing the "currenv" file $cat /proc/1/environ >> ...
4
votes
7answers
224 views

How to compare the same word between multiple files?

I would like to count the same words across multiple files then show in which file they are. File1: This is so beautiful File2: There are so beautiful File3: so beautiful The desired output 1: ...
0
votes
1answer
81 views

Comparing two files with an easy readable GUI program?

I would like to compare two large files that are not close to 1Gb in size. Kompare crashes when the files load is large. I configured Kompare as in the photo below: I would like to present the ...
1
vote
1answer
48 views

How alike/different are two binary files

I have some media files (right now it's video files, but I suspect I would also be able to use a good solution on picture files), that are very similar, but according to diff/cmp not identical. But if ...
1
vote
2answers
41 views

Comparing two separate directories for directories and files within

To compare the structure by iterating through each and every folder, I have tried to list the output(to a text file) of every directory and file present : diff --brief -Nr dir1/ dir2/ > out.txt ...
-2
votes
2answers
33 views

Filter the below text using shell commands

I am able to get the file difference using git diff command and I got it filtered like below: -This folder contains common database scripts. +This folder contains common database scripts. ...
3
votes
2answers
714 views

Side by side diff of large files

I have two ~1 GB files that I want to do a side by side diff of. Solutions I have tried: diff - Works quickly but doesn't output side-by-side. diff -y or sdiff - This outputs side-by-side but it ...
1
vote
1answer
26 views

Diff acting very strangely, reports long blocks as deleted when short bits throughout the block have been changed, deleted or added

I have two files, both are outputs from a code that I have put through cut to only look at the first 26 characters of each line. Both files are lists of parameters that the code measured, such as "...
1
vote
1answer
215 views

How to find which lines are different in a CSV file in the Linux command line?

Im trying to find which lines differ in between file1.csv and file2.csv. if file1.csv looks like this: 1,2,3,4 5,6,7,8 9,10,11,12 and file2.csv looks like this: 1,2,3,4 9,9,9,9 5,6,7,8 9,9,11,12 ...
0
votes
1answer
34 views

Print only what is exclusive to a file compared to another in Bash

Good day everyone, I know there are a lot of similar questions already answered, but I can't find a satisfying answer and it drives me nuts. I have two files which both contain hostnames : one that ...
0
votes
1answer
225 views

Use diff and ls to detect files that changed in remote folder

I have a remote directory with read access. I want to generate a list of files that changed since last iteration. My idea is something like: $ cp output.new output.old $ ll > output.new $ diff ...
0
votes
4answers
35 views

Getting Mismatched Entries In 2 Files [closed]

Problem..{ I've users with home dirs in /home, so I can get a list of users matching my criteria with following command. STEP 1: Fetching A List Of Users du -h --max-depth=1 /home 2>/dev/null | ...
2
votes
1answer
2k views

Compare two zip files for differences

diff command compares to see any difference betwenn two files. Can the same be used to compare two zip files, i.e if there is any difference in data ,like counts etc in individual files in the zipped ...
1
vote
3answers
989 views

Linux equivalent of windows cmd command

I'm migrating to Linux, and I need to convert the following Windows cmd command: fc file1.txt file2.txt | find /i "no se han encontrado diferencias" > nul && set equal=yes I think fc can ...
0
votes
0answers
20 views

Software for directory integrity

I keep a directory on my home server with all of my important files on it. I want to make offline backups of this directory. But as I add and modify file, I also want to be able to make comparisons ...
0
votes
0answers
21 views

Simple multithreaded diffing on macOS

I run diff -rq on terabyte-size directories in macOS. Is there a simple way to parallelize this process?
0
votes
2answers
885 views

Show only changed lines without syntax with git diff

I have a list of usernames that are in a text file. I update this file and commit it. I am looking for a way to get a list of the changes since the last commit. I do not want any diff formatting at ...
1
vote
1answer
278 views

Allow patch of symlinks

When I try to run a patch command with a patchfile against a link, patch gives me the error: File path/to/file is not a regular file -- refusing to patch The following command produces this error ...
1
vote
1answer
99 views

Diffing for metadata differences

Is there are way to use utility like diff to find the difference in metadata of two identical file hierarchies? If I have two identical file structures like root_folder/ file1 file2 ...
1
vote
1answer
37 views

Getting differences of file between specific revisions/branches

I have 2 different branches A,B that have a (slightly different) version of a file X. I am interested in getting the commits that added some specific patterns in branch B. What I do roughly: diff ...