Questions tagged [diff]

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

Filter by
Sorted by
Tagged with
0
votes
2answers
34 views

Compare large directories recursively ignoring sub-directories - compare two backups - with gui

I've got 2 very old Backups of a friends computer. They were simply copied into a folder each on an external Harddrive. Both are about 300GB in Size and the contents are very much alike but not ...
-1
votes
1answer
33 views

rsync completed in both directions, but size of directories is different. How it's possible?

I want to sync 2 directories (/src & /dst) to mirror all the files in both of them. Here is a steps: sudo rsync -vaP --stats /src /dst -> completed without errors sudo rsync -vaP --stats /dst /...
0
votes
0answers
39 views

How compare two binary files, showing long portions that match?

I have two pcapng files, and I'd like to compare them showing the matching portions and not. Basically, I know that in these 2 files each block header is different, but the block data are the same. ...
0
votes
2answers
25 views

Sync two folders via CD-based delta patch

I have a folder of data on a remote PC that gets weekly updates, delivered by CD. The folder is mostly .jar binary files - probably 200 of them, totalling around 350Mb in size. Only a small portion ...
-4
votes
1answer
44 views

i want a linux script that will be able to compare both files and after comparing it should display something

file 1 products total apple 6 yam 5 fish 6 meat 3 file2 products total apple 6 yam 7 ...
0
votes
0answers
15 views

Can we diff from different pipe to avoir create tempory files? [duplicate]

today I do: cat file1.txt | mystuff > tmp1 cat file2.txt | mystuff > tmp2 diff tmp1 tmp2 is there any way to not create these two tmp files?
0
votes
1answer
43 views

Can I use `diff` to display not the different but the matching parts?

man diff says: diff - compare files line by line So diff will compare the files. However, eventually, it will show the difference, if there is any. How can I compare the files and show the ...
2
votes
3answers
67 views

Diff with file titles printed out

I was wondering if there is way when the result is yelded from diff, to print the file names on top of the columns. Currently I get this ; diff -a --suppress-common-lines -y output_main.txt ...
2
votes
1answer
47 views

How to get linux 'diff' to work with regex expression in bash

I have two files, expected.out and actual.out with: PID(12345) PID(01234) respectively. I want diff to ignore the line if only the 5 numbers are different, so diff would return empty. The idea is to ...
0
votes
0answers
23 views

Maximize similarity of files by inserting white space

I have two trace text files from a PIN Tracer to compare byte by byte for an algorithm I am working on. They are largely the same, but differ in some places messing up the alignment. For example, here ...
1
vote
1answer
43 views

Diff identifying html files as binary

I may be missing some information here, but I was surprised today when I tried to run diff on two .html files that should have a subtle difference and got this message: $ diff index.html index3.html ...
3
votes
1answer
49 views

Find most closely matching files in two directories

I'm trying to find a solution for the following problem. I have two sets of files: Folder A has around 400 text files. Folder B has around 20 000 text files total in several subfolders. Files in ...
0
votes
1answer
28 views

Diff comparison and output to separate file

I want to compare multiple files with single master file and save it to separate file and also i want one csv file to mention the hostname with status column as change or no change. something bit ...
0
votes
0answers
34 views

How to compare two files and produce a third file where all differences are replaced by a marker?

What I am looking for is similar to a usual diff between files A and B, but that prints out a file C which comprises the common content from A and B, but also the diferences (replaced by some marker, ...
0
votes
2answers
194 views

How to make text wrap with diff -y?

When I use diff -y to compare two text files with long lines of text, the result cuts off each column and I cannot read an entire line. I would like instead the text to wrap (or fold as it is also ...
0
votes
0answers
29 views

Comparing Files inside Tar on Unix

I want to know how can I compare some files inside a tar one with these same files in one directory and if these file exists in the directory, proceed to delete them. I tried using diff and tar -tvf ...
0
votes
0answers
48 views

Process substitution doesn't work with diff and node

I'm trying to compare the output of my fizzbuzz.js program: for (let i = 1; i <= 100; i++) { let out = ""; if (i % 3 == 0) out += "Fizz"; if (i % 5 == 0) out += "Buzz"; if (i % 3 &&...
1
vote
1answer
125 views

How do I compare a command output to a text file?

I am learning some programming interview questions so I've coded FizzBuzz. I'm trying to comprare the output of my program to a known good output that's in a .txt file. How do I check that node ...
6
votes
1answer
214 views

diff shows a file that does not exist

I created a backup on an external hard disc. Then I created another backup and copied all files to another external hard disc. I wanted to check with diff if everything was copied: user@user:/media/...
1
vote
1answer
160 views

Using diff / patch to create a new file inside a directory

I'm learning about diff/patch and I don't understand why the patch file created by the command sequence below doesn't create the file create_me.txt inside the Org directory when I try to apply it. ...
1
vote
1answer
48 views

how to execute compound commands in shell script?

Here's my script: #!/bin/sh result=$((diff <(sort 1.txt) <(sort 2.txt))) if [[ $result != "" ]] then echo ERROR else echo PASS fi I got an error when execute this script: chk.sh: ...
0
votes
1answer
28 views

Apply a function on diff - possible?

I wonder if the following case is possible in Unix using the diff function. Let's say that I have one line 1234 1 2 and one file containing 1234 2 3 1234 represents the pid, 2 the disk usage and ...
0
votes
0answers
12 views

vimdiff show differences with only parent rows

Two config files contain many blocks of the form block name { ..... sub block name1 { ......... sub block name2 { .... } } ..... } Example: Input (LHS) : ltm ...
0
votes
1answer
45 views

comparison of two sorted files by common first field

I have to compare the IPs of two different /etc/hosts files and show a diff in side-by-side view. File hosts_sorted 10.244.74.152 REF_UP-4 10.244.74.154 REF_UP-5 10.244.74.156 REF_UP-6 10.244....
13
votes
6answers
4k views

How to compare two different files line by line in unix?

File1: 123 234 345 456 File2: 123 234 343 758 Expected output: File3: TRUE TRUE FALSE FALSE so the code should compare two files and print 'TRUE' if it matches otherwise it should print 'FALSE' ...
2
votes
2answers
340 views

Using diff to compare the output of two commands

How does one go about using diff to compare the output of two commands? I know how to use it to compare the contents of a file filename1 with the output of a command cmd2: cmd | diff filename - How ...
0
votes
0answers
92 views

Highlight differences between lines

I have a file with near-identical lines which have some slight differences, and I want to have a highlight of the differences between each line. Example: The quick brown fox jumps over the lazy dog. ...
7
votes
1answer
4k 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 structure looks like: temp/ |-- d1/ |-- f1....
2
votes
1answer
561 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
81 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
62 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
36 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/...
1
vote
1answer
552 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
818 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
177 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
59 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....
3
votes
1answer
190 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 --...
9
votes
1answer
2k 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 ...
1
vote
1answer
304 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
1k 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
2answers
91 views

awk compare two files and print first field in file 1

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
199 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
382 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
167 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
62 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 │ │ ├──...
2
votes
1answer
52 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
106 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
68 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
97 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 ...
3
votes
1answer
2k 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-...