Questions tagged [diff]
diff - Command-line tool to display the differences between two files, or each corresponding file in two directories.
554 questions
-1
votes
1
answer
75
views
patch fails on unified diff, but works fine with context diff
I am struggling with understanding how diff and patch are supposed to work. Here's my use case: I use Betterfox user.js config file for my Firefox profile, but I add some overrides to it. I want to ...
2
votes
1
answer
229
views
Unix or Linux command to compare binary files [duplicate]
I'm looking for a command that compares binary files.
Of course, I know about diff, but it is not very good at binaries.
I have two files from a error-prone source (scratched dvd) which should be ...
0
votes
0
answers
54
views
ubuntu system freeze while diff reading, SysRq REISUB not working
I've experienced total system freeze while checking if files where copied correctly by
diff -rq [INTERNAL HDD] [USB HDD]
This happened twice, always while running the diff. On the second occasion I ...
1
vote
0
answers
71
views
p4merge open each window minimized when running a git diff/ merge
I've asked the question on SO before, but maybe it is better placed here.
I'm running on Ubuntu 24.04.1 LTS (X11) and have p4merge installed in version p4v-2024.3.2656785.
I'm using p4merge since ...
0
votes
1
answer
100
views
How to save changes to patch files for kernel headers in `include/linux` using `diff`?
I am trying to hack the Linux kernel and added/modified some header files in include/linux. However, when I generate patch file using diff like:
diff -uprN -X linux/Documentation/dontdiff \
...
0
votes
1
answer
485
views
How do I compare two docker images?
I have two Docker images, each with many layers. I want to compare all the files in teh first image to all the files in the second one, to see what's been changed.
I tried taring up the images using
...
0
votes
2
answers
126
views
In bash/zsh, how to compare the metadata in two directories including . and excluding .. and the contents inside subdirectories?
Let's say that in a script, you have a directory $1 and its copy $2 and you'd like to compare the metadata (names, permissions, sizes, full modification dates, …) of the files and directories inside ...
0
votes
0
answers
264
views
diff -qr command between local and remote directories
According to this process substitution can be used to do a SIMPLE diff between local and remote machine. However, I want to use the -qr option in the diff command, i.e., it must be recursive and brief ...
0
votes
1
answer
134
views
How to quickly find the largest files/dirs that differ between two directories that should be identical on Linux?
I'm trying to synchronize two hard drives. I thought most people who don't want to lose any data and don't use RAID would use such a method so that there would be a well-working GUI. That doesn't seem ...
0
votes
1
answer
51
views
check files difference with multiple folders
I would like to check when a file differ inside a backup system using snapshots.
I have several folders with the same architecture inside
ls -1 .snapshot
4-hourly.2024-04-14_0405
4-hourly.2024-04-...
0
votes
1
answer
74
views
How to prevent `diff -rq` from showing newly created files, when comparing the different versions of a folder?
I am doing diff -rq to check the difference between 2 folders (A and B). I don't want to know if folder A has any new files because that's expected. How do I ensure that this information doesn't come ...
0
votes
1
answer
104
views
How can I call git's built-in diff command directly after configuring a different visual "git diff" substitute?
I have configured git diff to be a command that calls substitute diff for viewing file differences i.e /usr/bin/vim -dR "$2" "$3" and that doesn't work when I want to create a ...
0
votes
1
answer
161
views
Performing character-level comparison of "strings" without explicitly creating temporary files for git diff
Referring to this https://stackoverflow.com/a/31356602, I wrote this code:
#!/bin/bash
# Define the two strings to compare
string1="First string with some random text."
string2="Second ...
0
votes
2
answers
323
views
Fast file comparison that displays results side by side with structure understanding (a la total commander in windows)
Is there a way/tool to show differences between two files side by side only highlighting differences in a similar way kdiff3 does that but with a tool that is reasonably fast?A similar question was ...
2
votes
1
answer
1k
views
How to use kdiff3 to edit when comparing two files
I'm used to meld for editing while seeing an intra-line diff that's updated live in response to edits. One just types in the left or right pane of the window and then save one or both files.
I'm ...
1
vote
0
answers
118
views
When should I use comm over diff?
It seems diff can do anything comm can do? When should I use comm only but not diff excepting the difference in result format? I guess comm is faster?
2
votes
3
answers
543
views
How to compare two directories recursively, and for each pair of files with the same name, location, and contents, say which file is older?
In a Linux shell, how to compare two directories recursively, and for each pair of files (including symlinks and directories) with the same location (including the name) in the two directories and the ...
1
vote
1
answer
843
views
How to compare minimised JS files with very long lines? diff prints whole lines which is unreadable (400k characters per line)
I need to compare two "minimised", very similar JavaScript files. Minimisation means that (among other things) newline and space characters that are not needed for interpretation by a ...
0
votes
0
answers
68
views
How to diff command outputs in vim
I tried vim -d <(ffprobe one.mp4 2>&1) <(ffprobe two.mp4 2>&1) to see the difference between the two videos' codecs etc., but vim doesn't show anything when it opens, just an empty ...
0
votes
1
answer
128
views
Compare text in pdfs when text has been re-flowed
I'm trying to compare text between two versions of a PDF document. I was able to create a diff with pdftotext, format some replacements with perl and colordiff.
This output a lot of differences, but ...
2
votes
0
answers
49
views
diff -s command says text files are identical when they are not, in zsh on macOS [duplicate]
I've observed unexpected behavior (that seems to be a bug) in diff in recent versions of zsh on macOS, the problem is specifically with the -s directive. diff -s lists difference, but it always adds ...
0
votes
1
answer
894
views
No such file or directory
I'm trying a command and when I enter it the first time it tells me:
diff: llet: No such file or directory
but then when I try it a second time, it works... Is there a reason why?
Here's the command: ...
1
vote
0
answers
180
views
diff two multilines bash variables to list what lines aren't in the other
I've created a bash script that
Lists the document IDs I've put in an Elastic index, in $liste_ids_lines:
a004-événements-examen_individus_localisés_ou_non
a020-les_points-leurs_indicateurs-...
0
votes
0
answers
72
views
Help with creating a bash code to compare two different files
I'm currently encountering some challenges while working on a bash script in the Linux terminal to perform the following tasks:
Compare the values in the third column of two different files line by ...
0
votes
1
answer
58
views
diff and comm are not finding difference between two env files
I have this env file
1.env contents:
BARF_BAG=1
then another env file:
2.env contents:
BARF_BAG=2
I run comm and diff on the files to see the difference:
#!/usr/bin/env bash
(
set -e;
...
0
votes
1
answer
71
views
Group results using comm
Using comm I get results that look weird from this:
comm -3 <(. "$first_env_file"; env) <(. "$second_env_file"; env)
I get something like:
AUTH_LP_ACCOUNT_ID=xxx1
...
1
vote
1
answer
1k
views
diffing two .env files
I have two env files, let's say x.env and y.env, the order of the variables is different, but the content could be the same but likely different.
Is there some tool I could use to diff the variables?
...
0
votes
1
answer
63
views
Force Patch character differences to a file
Hello,
I have an englishStrings.json file and when I make new edits/ additions to it, I need to copy the new changes to all the other language string.json files.
Before making any changes to ...
-1
votes
1
answer
108
views
Complicated DIFF method
I'm trying to do a compare between a config from an old box and a new box to verify Availability and State haven't changed.
I have a file that is generated with about a thousand nodes but every node ...
0
votes
1
answer
801
views
Best way to compare/diff two big directories that are backups (by `rsync -aAX`) of a boot partition from another computer?
[ EDIT:
Answered my own question.
Used unison and some hacky post-processing
(
copy-pasted the log output of unison,
tweaked it in my text-editor with multi-selection editing,
then did some shell ...
0
votes
1
answer
51
views
Is there a diff(1) that calculates deltas over numbers on each matching line? [duplicate]
Is there any form of diff that detects matching lines, i.e., lines containing the same text, except for numerical values (decimal, octal, hexadecimal), and then calculates the delta for those numbers, ...
4
votes
1
answer
471
views
How to use `-s` option of `diff` command
I am using the command(diff) on macOS. The document says:
-s --report-identical-files
Causes diff to report files which are the same, which are
otherwise not mentioned.
...
1
vote
4
answers
209
views
Remove Specific Strings from Text Files to Compare/Diff
I am trying to compare two text files but I need to edit them first to ignore certain strings. Here is an example of one text file:
Processing Server ABC-123
oracle 10785 1 0 May17 ? 00:...
1
vote
4
answers
185
views
Find text files where the content is duplicated?
By mistake I appended (>>) rather than overwrote (>) the output from a script that processed thousands of files, but I only did it for about 20 % of the files (I ran 5 parallel instances of ...
0
votes
1
answer
48
views
Is it possible to make diff suggestions in vimdiff?
I'm comparing two files in vimdiff. For one section of the code in the first file, the same section in the second file has several lines of code added, and then a slightly modified copy of the section ...
1
vote
1
answer
63
views
How to generate a list of daily changes to my notes?
Background:
I use Obsidian to organize my notes as I study. It's an application which works "on top of" a collection of markdown formatted plain text files and then shows the links and ...
3
votes
1
answer
122
views
Why diff3 on inputs from process substitution finds a difference while diff3 on same data in files finds no difference?
diff3 on files finds no difference:
$ grep -P '\[\[.*?\]\]' -o intro.tex | sort > A.txt
$ grep -P '\[\[.*?\]\]' -o intro.tex | sort | uniq > B.txt
$ grep '\\pnum %% \[\[' intro.tex | sed 's/\\...
0
votes
1
answer
1k
views
Return list using git diff and grep
I'm using git diff to return the file names of files recently changed and i'm trying to pipe the returned file names into a grep expression that searches each file and returns the files that have &...
1
vote
1
answer
3k
views
ansible comparing all files in 2 directories and printing the difference
I have 2 directories
$ tree dir{1..2}
dir1
├── file1
└── file2
dir2
├── file1
└── file2
I want to compare all files in dir1 with all files in dir2 using ansible
and print differences like this
output:...
0
votes
1
answer
319
views
What is the purpose of timestamps in unified diffs?
An Example of Unified Format:
--- lao 2002-02-21 23:30:39.942229878 -0800
+++ tzu 2002-02-21 23:30:50.442260588 -0800
@@ -1,7 +1,6 @@
-The Way that can be told of is not the eternal Way;
-The name ...
0
votes
0
answers
111
views
diff: delete one line and then add another - what line number is meant in the add command?
There are two files, a and b, with such contents:
a
apples
oranges
kiwis
carrots
b
apples
kiwis
carrots
grapefruits
Next, I do diff for them:
$ diff a b
2d1
< oranges
4a4
> grapefruits
After ...
0
votes
0
answers
23
views
Find difference in two set of files in linux [duplicate]
I have two sets of files containing ip addresses
file 1
1.1.1.1
2.2.2.2
3.3.3.3
file 2
1.1.1.1
2.2.2.2
4.4.4.4
5.5.5.5
I need to compare two file and print the entry present in file 1 but not in ...
0
votes
0
answers
419
views
Patch malformed error
patch: **** malformed patch at line 225: diff --git
the line 225 is this one :
diff --git a/files/etc/Compile_info.txt b/files/etc/Compile_info.txt
I have a many patches in one file patch and I ...
2
votes
2
answers
1k
views
How to apply a patch as part of a pipe? In other words, how to patch stdin?
I want to apply a unified diff from mypatch.diff to stdin and output the result to stdout.
So far, I have tried:
patch -i mypatch.diff -o - -u originalfile
Which successfully applies mypatch.diff and ...
-1
votes
1
answer
520
views
I need to compare/sort two text files
this is the scenario. I have File1 and File2 and i like to have the outcome in File3.
I'm kind of new to Linux, but so far ive tried to use sort, diff, and comm. but no luck so far.
File1.txt File2....
0
votes
0
answers
122
views
mv and cp with automatic diff
Is there a program out there like mv and cp, which upon conflict automatically shows a diff before asking whether to override the target file?
This is such a basic feature in graphical file managers,
...
-1
votes
1
answer
69
views
find the different string from file comparison in unix
I have 2 files:
File1:
DX 100860599215|732512737|00002|40|1|20220105|20220105|20220523|31014280|5892720|36907000|1|20220105|40|20|D|
File2
DX 100860599216|732512737|00002|40|1|20220105|20220105|...
-3
votes
2
answers
1k
views
How to get difference of two csv files by columns and write diff into 3rd file?
I have two csv files like this;
422174,XN,20.99,2020-09-01,2022-01-20 20:20:28.613+00
421348,SB,21.99,2021-01-26,2022-01-20 20:20:28.613+00
885176,XN,41.80,2021-11-17,2022-01-20 20:20:28.613+00
881751,...
-1
votes
1
answer
915
views
How to get difference of two csv files and write diff into 3rd file?
I have two csv files like this;
422174,XN,20.99,2020-09-01,2022-01-20 20:20:28.613+00
421348,SB,21.99,2021-01-26,2022-01-20 20:20:28.613+00
885176,XN,41.80,2021-11-17,2022-01-20 20:20:28.613+00
881751,...
10
votes
1
answer
1k
views
Space not taken as an argument separator by shell script (could someone please explain that small file difference ?)
SHORT VERSION (TL;DR)
I have 2 small one-line files, seemingly identical :
$ cat f1 f2
./cconv.sh 100 EUR USD
./cconv.sh 100 EUR USD
But they are not, there is a 1 byte difference in size :
$ ls -l ...