Stack Exchange Network

Stack Exchange network consists of 174 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
votes
1answer
25 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,...
0
votes
1answer
29 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
26 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
55 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
30 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
77 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
63 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
354 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
36 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
74 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
905 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
172 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
27 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
50 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
174 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
53 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
37 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
36 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
31 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. ...
1
vote
2answers
256 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

Apologies for the title gore, I ca not think of a decent way to explain what is going on without a lot of words. I have two files, both are outputs from a code that I have put through cut to only ...
1
vote
1answer
49 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
29 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
132 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
30 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 | ...
1
vote
1answer
685 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
773 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
18 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
20 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
380 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
112 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
39 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
35 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 ...
1
vote
1answer
115 views

How to undo after patch is applied? .rej/.orig files

The case is following. I have two files: file1.c, file2.c ls file1.c file2.c patch.diff patch < patch.diff ... x out of x hunk FAILED -- saving rejects to file file1.c.rej (the same with file2.c)...
2
votes
0answers
62 views

How to highlight output from diff command and make them side by side?

I have two files $ cat file1.txt UUXX:1 UUXX:2 $ cat file2.txt UUXX:3 UUXX:1 I want to use this command $ diff --old-group-format=$'\e[0;31m%<\e[0m' --new-group-format=$'\e[0;31m%>\e[0m' --...
1
vote
2answers
60 views

Find the difference between two list

I desire to compute the difference of two lists: $ pip list > package1.md Package Version ---------------------------------- --------- alabaster ...
0
votes
1answer
253 views

Apply patch to multiple different name

Is it possible to apply patch to different file name but with the same structure. The case was, I have a patch of a file with specific name and then for some inevitable reason that file got changed ...
0
votes
1answer
47 views

Change in shell script

I was using a bash script to do some automated testing on a CLI. All of a sudden it does not seem to work. Seems like our devops have done some changes to the OS. The error i see is bash-3.2$ sh ...
1
vote
0answers
57 views

Diff of PDF files leaves garbage on next command line [duplicate]

I would call this a curiosity more than a problem or anything else: When using diff on two specific PDF files that are similar but not the same, I get some garbage dumped on the next command line. ...
0
votes
2answers
193 views

How to write the difference between two files into a file

Saying that I have two files: a.txt and b.txt. The content of a.txt: hello world The content of b.txt: hello world something else Of course I can use vimdiff to check their difference, I can make ...
0
votes
2answers
41 views

Diff filenames of two directories?

So, I've run the ls -C1 on two directories: mod@ux:~$ ls -C1 /bin | wc -l 165 mod@ux:~$ ls -C1 /sbin | wc -l 167 How to list only different filenames/commands and which directory contains them?
2
votes
2answers
757 views

Diff between local and remote directory

I want to compare my local directory and remote directory. Example: Consider 2 directories as local and remote directory |-local | |--aaa | | |--file1 | | |--file2 | | | |--bbb | | |--...
2
votes
1answer
210 views

Using output of diff -e with sed

I'm currently attempting to change the contents of one file orig.sas to match the contents of an updated file new.sas Replacing orig.sas with new.sas makes some of the changes, but there are ...
0
votes
1answer
51 views

diff of config files showing only uncommented lines

Consider the need to use 'diff' to compare two files with many commented lines, such as system configuration files. (For example, the files could be /etc/cups/cups-files.conf.pacnew and /etc/cups/cups-...
0
votes
3answers
50 views

Trouble with piping

Why I can't do something like: tail -n 5 small.txt | diff small.txt I want to pass the execution result of the first command like second argument of the second, not stand alone input. How can I do ...
3
votes
2answers
1k views

diff - how to ignore empty lines

I need to diff two files ignoring all whitespaces and empty/whitespace lines but for some reasons diff options I found does not do all well, it keeps showing the empty line in file1... $ cat file1 2 ...
1
vote
2answers
49 views

How to get the modified files(before and after) from git version server?

Now here is the commit id 41f9f4e392ab50db264e0328de7d69f1f10646eb, I want to get this commit id code which were modified only. I use git show 41f9f4e392ab50db264e0328de7d69f1f10646eb to see modified ...
0
votes
0answers
65 views

diff where chunks of lines are out of order

So my question is related to : diff where lines are mostly the same but out of order? but is slightly different, in that in this case sorting won't work. I have 2 files and I want to do a diff ...
0
votes
1answer
142 views

Fuzzy diff n by n files

I want to know the individual difference between n files, so similar to this: parallel --tag 'diff {1} {2} | wc -l' ::: * ::: * A big problem here is binary files, and a single megalong line will ...
1
vote
2answers
193 views

Given two files, how do I find the total number of line changes?

I tried using this command to compute number of lines changed between two files: diff -U 0 file1 file2 | grep ^@ | wc -l My problem with this command is that if one file has only one line, and the ...