Questions tagged [diff]
diff - Command-line tool to display the differences between two files, or each corresponding file in two directories.
447
questions
0
votes
2answers
48 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
0answers
41 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 in linux.
I have tried all the variants of diff, but the problem is that the process is soon aborted and ends with "memory ...
1
vote
2answers
39 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
351 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
9 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
32 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
49 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
38 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
71 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
68 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
24 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
22 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
48 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
37 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
34 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
24 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
44 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
554 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
32 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
32 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
165 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
69 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
24 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-...
0
votes
0answers
29 views
ANSI characters not displayed properly in terminal(konsole)
While using manual/git/possibly other applications my output is full of garbage characters(which looks like ansi characters).
Example output:
[1;36mDESCRIPTION[0m
[1;36mman[0m is the system'...
-1
votes
1answer
37 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
18 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
36 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 ...
0
votes
1answer
806 views
diff command to compare 2 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?
...
1
vote
1answer
1k views
Is there any better way to filter the output of git diff?
SO Question in Context : Find out changed line numbers from git diff
Based on the question above, I need to print the diff for modified files between two revisions in git in this format :
/path/to/...
0
votes
2answers
49 views
How to verify that files in A folder are also in B folder
I use my synology DS1515+ and DSM 6.2.2.
First of all, please refer to the picture as below;
First, I download some video files. Examples of filenames are as above.
And second step is that copying ...
5
votes
3answers
482 views
Find files that have the same name as the directory
I have the next problem:
Directory Example1 has three files: Example1, Things and Pictures.
Directory Example2 has three files: Example2, Example3 and Pictures.
I need a list showing only the ...
0
votes
1answer
209 views
how to compare two pipe delimited text files, find out the difference and copy the output to third file using linux script
I want to compare two pipe delimited text files and find out the difference between two files using Linux script and write/copy the difference to output file.
scenario 1
File 1
5756366|99|HOLDER, ...
2
votes
5answers
122 views
Compare 2 files based on the first column and print the not matched
File# 1:
test1,1
test2,2
test3
File# 2:
test2
test1
test4
Desired Output:
test4
1
vote
1answer
54 views
Is there an equivalent of zdiff for zstandard
Is there an equivalent of the gzip utility zdiff(1), but for zstandard?
I have not been able to find anything in the zstandard repository other than zstdgrep and zstdless.
0
votes
1answer
71 views
How does rsync work in this simple example?
Let's say:
a is a 256 MB file containing random bytes
b is the same file except it has one additional leading byte 0
Thanks to this answer, I discovered that rsync is able to compute a "binary diff ...
14
votes
5answers
4k views
Diff of two similar big raw binary files
Let's say I have a 4 GB file abc on my local computer. I have uploaded it to a distant server via SFTP, it took a few hours.
Now I have slightly modified the file (probably 50 MB maximum, but not ...
0
votes
1answer
26 views
Is there any GUI comparison tool to check folders in two machine?
Some of my dev machine is one network and test machines in different network. Due to this often we are changing code in test machine and validate it then move the code to dev machine.
I know this is ...
0
votes
2answers
228 views
Compare large directories recursively - but 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
281 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
256 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
65 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
47 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
1answer
49 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
120 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
137 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
24 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
212 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
155 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 ...