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
1answer
45 views

diff: what does this output indicate?

I am using the following command to log the difference between two files on my disk to a log: diff --color=always -sy --suppress-common-lines --suppress-blank-empty file1.c file2.c >> diff_log....
3
votes
2answers
146 views

git diff: create custom function/macro to ignore comments

I have following function in zsh, which basically works as diff, but it ignores comments (lines starting with # or empty lines) when comparing files: function cdiff() { local args=("${(M)@:#-*}&...
1
vote
1answer
28 views

recursively diff two directories ignoring a single word

I would like to diff two directories recursively, ignoring one particular string replacement. For example, in one directory, some files contain the string "abcd" whereas in the other ...
1
vote
1answer
42 views

How do you merge files with dispatch-conf?

Sorry for such a simple question, but I can't figure this out for the life of me. Neither DISPATCH-CONF(1) nor wiki.gentoo.org/wiki/Dispatch-conf provide any instructions. When running dispatch-conf: ...
1
vote
1answer
31 views

How to measure the similarity or the distance between human readable text files (license files)?

I want to find out which license a source tree has. The computer should make a suggestion which license files match closely. Then I would like to compare the texts with meld manually. In a typical ...
3
votes
2answers
323 views

Why downloading the same web page twice with wget results in two files which differ?

I'm trying to write a script that notifies me when a static web page has changed. To do it, I'm using wget to download the web page, and diff to check whether it has changed or not. I'm running an ...
0
votes
0answers
14 views

Hide non overlaps but show all three versions in diff3

diff3 calls the same change in both branches a non overlapping conflict. --show-all bothers you with these mostly harmless changes. --show-overlap accepts them, as I want, but doesn't show you the ...
0
votes
2answers
46 views

Compare content of two folders/disks (including timestamps,permissions)

I have two directories on two different hard drives and want to check if the content is really exactly the same. From what I read I can use diff -rq dir1 dir2 to check if files are missing or differ. ...
0
votes
0answers
20 views

Colorizing a diff of diffs in git

The setup I wrote a script that checks if a merge commit was resolved successfully by displaying a diff of diffs before an after the merge. For example, if my history looks like this: * 5c8cb0d2 merge ...
2
votes
2answers
59 views

Can I ignore certain irrelevant lines when creating/applying a patch with diff/patch?

File A Apples Bananas Clementines Dates File B Apples Blueberries Cherries Dates I want to diff A and B to generate a patch that when applied to C will change the line Clementines > Cherries but ...
0
votes
1answer
43 views

How to use sed to remove letters, numbers, spaces, hyphens from the same linux string

I am trying to create a script to monitor a web page and send a telegram notification whenever there is a change in that page, I am using diff to accomplish this task. The script seems to work well ...
0
votes
1answer
29 views

how to diff automatically between file.txt.orig and file.txt

Currently, I am editing files on vim by setting patchmode=.orig and then, having two files: file.txt.orig <- backup without changes file.txt <- update file However, I would like to generate a ...
0
votes
0answers
7 views

Packaging an Ubuntu DIFF from a package repo for application to an offline mirror

I have a situation where I have an offline Ubuntu mirror that I need to update. I cannot bring it online so I need to apply updates based on the current state of the offline mirror and the current ...
2
votes
2answers
68 views

Display git-diff between master and my last commit

I use git on a regular basis for collaboration with other people. When we work together on a shared repository, I'd like to be able to view the changes performed by others which happened between my ...
0
votes
0answers
15 views

Generate shell script which eliminates differences between two directories

I would like to compare two directories and then generate shell script which turns "target" directory files with "source" directory files. It should copy the changed files from ...
0
votes
0answers
29 views

Patch unable to find file

I am currently in directory - /usr/lib/llvm-9/build The include/ directory is a symlink - reikdas@reikdas-VirtualBox:/usr/lib/llvm-9/build$ ls -l lrwxrwxrwx 1 root root 10 Jan 31 2020 include -> ../...
0
votes
1answer
27 views

Rebasing a patch without using git?

I've never used maintained files created with patch and diff. But what is the work flow when the patch drifts? As in this case. I can see the the failures when I do -m in the same format git would ...
1
vote
0answers
18 views

Merge two corrupted copies of same file to fix errors / finding parts of files of same size that differ

Having mirror copy of hard drive I noted few files became different one copy from another (by sha256 check). I would like to merge these two to several versions of file one of which I hope would be ...
0
votes
1answer
29 views

How to list all files that occur SOMEWHERE in one folder but not another?

I have a folder with a lot of subfolders and files (let's call it 'orig'), and another folder where a lot of the same files were placed as backups in a different folder structure (let's call it '...
0
votes
1answer
63 views

What does 'grep -v “^[…]”' mean?

I wrote a line like this diff fileA.txt fileB.txt | grep -v "^[11,12d9]" . Without the grep part, the output would look like this: 1d0 < loop 11,12d9 < polo < pool But ...
1
vote
0answers
132 views

diff doesn't return anything, but total size is different?

Usually I like to use a following diff command setup to recursively compare 2 directory structures: diff --brief --recursive dir/one dir/two However on my last attempt it returned nothing, so I ...
0
votes
2answers
99 views

Unix Commands Questions - mv, pwd, chmod, and others

I wanted to make sure Im matching the correct command to the description, including possible tags I may need and I'd really appreciate if someone could confirm them for me: Show file permissions for ...
0
votes
1answer
87 views

Efficient way to get the difference between two files in linux?

I've been trying to get the difference between two huge .txt files (> 6Gb each) in linux. I have tried all the variants of diff, but the problem is that the process is soon aborted and ends with &...
3
votes
3answers
318 views

grep within a git diff, but show file and line number

When I'm working on a branch, I want to quickly jump to my "TODO" comments. This means I only want "TODO" comments that were added on my branch (ignore the ones in master) I want ...
4
votes
4answers
511 views

How to merge two folders so as to remove identical files from one, while keeping checksummed differentials?

I have a scenario where I have a recovery from a drive from possibly a different point in time that is not only potentially different in terms of files being present, but also there was some ...
0
votes
0answers
11 views

Emulate diff3 (git-style file merges) with busybox

GNU diff3 allows git-style potentially conflicting file merges Busybox does not support diff3, but instead supports diff and patch Is it possible to emulate diff3 result somehow? Context: I am looking ...
0
votes
2answers
63 views

Reconstruct file from diff

Say I have a file foo and a file bar. I now call the following commands: $ diff foo bar > diff_foobar $ rm bar Is there a(n easy) way to programmatically reconstruct the missing bar from foo and ...
0
votes
2answers
226 views

Can I write comments inside a “normal” diff/patch file?

I used diff to produce a patch file. diff old.txt new.txt: 1c1 < Lorem ipsum dolor sit amet, consectetur adipiscing --- > The quick brown fox jumps over the lazy dog. The output is in the ...
1
vote
1answer
42 views

How do I diff 2 folders by file name, but just the beginning of the file names using zsh?

So I have 2 folders with a lot of similar files, and the version is written in the filename, so what I wanna do is check if the beginning of the filename is the same (for example "sample-1.12&...
0
votes
1answer
118 views

diff marking each line as old, new, or unchanged

I need to diff two unsorted text files with the output marking every line as either old, new, or unchanged. The marks should appear at the beginning or end of the line, and there should be no other ...
0
votes
2answers
95 views

Using sed to cut and add to specific lines of diff output

I have the output from my diff command between two directories store in a file called differenceOutput.txt. At present there are only two kinds of lines in differenceOutput.txt So all lines have ...
0
votes
0answers
30 views

diff tool slows down wifi?

I was downloading some large files(several GB each) simultaneously, and wifi was above 10 MB/sec, all fine. Then I launched a diff locally, on some other large files, and cpu usage went up, from ...
3
votes
0answers
76 views

Find the (likely) git commit from which a version was branched

I have a directory containing files that were originally checked out from Git, then modified. Unfortunately, I don't have any of the Git metadata. I'd like to know what Git commit that directory's ...
2
votes
1answer
29 views

sdiff usage regaring merging changes in to an output file? How to come out of edit mode?

I tried sdiff file1 file2 -o file3 and everything seems to be going well. I could enter l or r to choose left or right side content in to the output file. But for a particular change, I had to edit ...
0
votes
0answers
25 views

Compare each line of file1 with file2 and print the contents of file1 which is not present in file2

file1 A B C D file2 A D E F I would like compare each line of file1 with file2 and print the contents of file1 which is not present in file2. what's the best Linux command either join, diff or some ...
1
vote
1answer
113 views

Can `patch` be idempotent?

Can patch be invoked with idempotency; i.e., is there some combination of options that will cause repeated invocations of patch to have the same effect as a single invocation of patch (for a non-empty ...
0
votes
1answer
240 views

Linux diff command not showing right comparison

I really need your help to advice how to show the correct comparison test using diff command. I have two files FileA: 2 1 3 4166 4 1186 5 14318 6 ...
1
vote
1answer
84 views

How to make diff print non-ascii characters in file names?

I have directories with non-ascii characters, and when I diff them, the diff output shows escape sequences instead of the utf8 characters: robert@saaz:~$ mkdir foo föö robert@saaz:~$ echo 1 > foo/...
2
votes
0answers
28 views

How to compare RAID mirror elements?

I've got a RAID mirror (md1) with three devices (sdc, sdd, sdf). Something went wrong overnight, the array went readonly, and fsck found thousands of inodes with inline_data_fl set and/or on the ...
3
votes
1answer
54 views

Comm/Diff (or alternative) that respects glob characters: is this possible?

Restricting "globbing" grammar to, specifically, suffix-globbing, * characters only, suppose I have: // foo.txt foo.* biz // bar.txt bar foo.bar And I would like to write: diff <(sort -...
5
votes
3answers
1k views

I want to compare values of two files, but not based on position or sequence

Suppose that I have the two files with the following content: $ cat File1.txt Apple orange watermelon avocado lime $ cat File2.txt orange Apple lime watermelon avocado Basically, there is no ...
2
votes
0answers
39 views

Patch apply at wrong location

I'm attempting to create a set of patch files that i can quickly apply on demand to add or remove alias to .bashrc. To arcive this i added a section for alias in .bashrc after the line # alias and ...
0
votes
1answer
71 views

Compare files in folders of local machine and remote server

I want to compare and note the files that are different in a folder of my local machine with a folder on remote server. I want to check all subfolders within this folder as well. But not copy from one ...
2
votes
4answers
392 views

Diff only words in files

I have two files I need to compare. Problem is, indentation and newlines have different formatting so just diff file1 file2 returns the entire output of both files. Is there any way to ignore ...
0
votes
1answer
237 views

How do I check the result of a command for an output vs no output in zsh if statement?

I would like to compare 2 files using diff and then if it returns nothing then echo "no diff" else display the difference. My current if statement only works if there is no difference but if there is ...
0
votes
1answer
28 views

How to review changes made by a .patch with quilt in a Debian source package?

I've pulled the source package of luajit with apt source luajit from Debian sid. As the package was unpacked by the same command, I saw the next message: dpkg-source: info: applying 0002-Enable-...
-1
votes
1answer
53 views

What's the use of -Nur switch in diff command?

I'm using Ubuntu 20.04, and I'm learning Gnu/Linux from edX. There's an exercise that has the following command: diff -Nur group GROUP > patchfile And I've no idea what the -Nur switch does here. ...
0
votes
1answer
20 views

How do I patch in to a file only the insertions and modifications leaving the unmodified lines there?

I have a short file (around 60 lines) which acts like a basic database it has three whitespace separated columns. The first one is name of the product, the second one is the price and the third one is ...
0
votes
1answer
65 views

Reflink copy diff

I want to make a behaviour like btrfs send and btrfs receive, but on a per-file basis. As far as I see it, I can use cp -ax --reflink=always to make a "snapshot" of the file. Let's assume that two ...
3
votes
2answers
3k views

Using the diff command to compare two strings?

According to https://www.computerhope.com/unix/udiff.htm The diff command analyzes two files and prints the lines that are different. Can I use the same diff command to compare two strings? $ more ...

1
2 3 4 5
10