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
0 answers
21 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
30 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 ...
  • 97
1 vote
2 answers
88 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 ...
  • 2,260
-1 votes
1 answer
59 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....
  • 1
0 votes
0 answers
51 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, ...
  • 489
-1 votes
1 answer
30 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|...
  • 1
-3 votes
2 answers
226 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,...
  • 27
-1 votes
1 answer
176 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,...
  • 27
10 votes
1 answer
903 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 ...
  • 1,279
2 votes
0 answers
50 views

How to limit "diff -r" to a certain depth?

How can I compare sub-directories in two directories down to a certain directory depth? Command diff doesn't have an option to specify depth, and -r option takes you all the way down to the files, ...
  • 121
0 votes
1 answer
124 views

Diffing two directories well

I need to diff (and merge) two directories (practically same content, with a few extra inserted lines in one set of files). Alas, all diff programs I tried (kompare, diffmerge, kdiff3, diffuse, xxdiff,...
0 votes
2 answers
76 views

How I can get the missing lines from a.txt files using diff?

I have the following files: a.txt 1 2 11 22 33 444 b.txt 1 2 3 11 22 33 555 I want to retrieve the lines from a.txt that do not exists on b.txt. I tried with that: diff a.txt b.txt -d 2a3 > 3 6c7 ...
3 votes
3 answers
118 views

Merging two non-git-based text files with similar semantics to the depiction of git merge conflicts

I would like to merge two non-git-based text files using semantics that are similar to to how git depicts "merge conflicts". For example, suppose I have two text files with similar but not ...
  • 445
1 vote
1 answer
48 views

How to display line differences between 2 files while considering "modified lines"?

I have 2 files file1 and file2 that are sorted and contain mostly similar lines. I want to display added/modified/suppressed lines between these 2 files. The catch is in the definition of a "...
  • 11
0 votes
0 answers
53 views

How to get binary diff size of two folders

I need to know the size (in bytes) of binary difference between two folders containing hundreds of files. ideally searching for a tool where something like xtool --recursive /path/to/folderA/path/to/...
-1 votes
1 answer
60 views

Machine readable output of "diff -r"

Is there any machine readable output for comparing two directories with diff? If I do diff -rq a b I get: Only in a: aa Only in b: bb Files a/t and b/t differ But maybe something like the following ...
0 votes
1 answer
97 views

Have git diff color customization

How can git diff color be changed to one's disposal, or such as for diff ...? in ~/.gitconfig: [color "diff"] added = yellow changed = red bold not work. Please sincere help appreciated
0 votes
0 answers
20 views

How to patch source code tree from within the dir to be modified?

A source code tree contains a modified dnsmasq-2.80test4 source (and git files). Now I'd like to apply the newest 2.86 dnsmasq source code to that modified 2.80test4 using diff and patch, while ...
  • 4,566
0 votes
0 answers
115 views

Why does meld get stuck on my remote 3-way comparison?

I'm running a 3-way merge using meld (via git mdiff actually) - on a remote machine. My own machine is Windows 10, and the remote machine is Devuan GNU/Linux Chimaera. While the meld window does come ...
  • 8,143
1 vote
3 answers
504 views

Recursively list path of files only

Why I have two folders that should contain the exact same files, however, when I look at the number of files, they are different. I would like to know which files/folders are present in one, not the ...
  • 13
1 vote
1 answer
53 views

How to change diff side by side markers to other ones?

I use diff -y <file1> <file2> or sdiff <file1> <file2> but I can't find how to change markers from the defaults which are: < > | In particular, I would like to add a ...
0 votes
1 answer
110 views

patch without reject

This might be answered already but it is hard to search for -- basically, When patch find a block/hunk unable to apply, it will reject the changed hunk into reject file. How not to put the conflicts ...
  • 977
3 votes
2 answers
346 views

Extract the indexes of rows that are swapped in order between two files

I have two large tab-delimited files (>10GB) and I know that when they're sorted, they're identical in content. However, I'm interested in the order of rows and the index of the swapped ones when ...
  • 257
0 votes
1 answer
250 views

why diff command returns the identical information from two files in linux?

I have two sorted files and each only has one column. the first 45 lines in both of them are a bunch of numbers and they are the same between file1 and file2. when I used the diff command it returns ...
-1 votes
1 answer
82 views

Search for a patter grep in file

I have the output of diff in the format below: $ curr_dt=$(date +%m_%d_%Y) $ echo $curr_dt $ diff -q /POC/$curr_dt/DDL/ /POC/Backup/DDL/ Only in /POC/Backup/DDL/: comp1.txt Only in /POC/Backup/DDL/: ...
  • 57
0 votes
1 answer
149 views

Compare two files in Unix

Consider two files like below: $ cat f1.txt col_name data_type comment name string age int income int access_count1 int ...
  • 57
0 votes
1 answer
50 views

Confusing Results from diff

I got the following results from diff: @@ -4479,7 +4479,7 @@ || AddPrintCheckParameters(TRUE) || AddRecipeDefaults(TRUE) || AddRepeatScanPass(TRUE) - || AddVirgoFlag(...
  • 197
0 votes
2 answers
808 views

how to compare all files inside ONE directory in bash?

example given: dir1/ file1 file2 file3 file4 how do you compare file1-file2, file1-file3, file1-file4 then file2->file3, file2->file4 and so on. In this case the name is file_number, but ...
  • 280
0 votes
1 answer
293 views

looking to compare two directories using boolean statement

just looking to compare two directories and make sure that all files reside in both, I'm aware of the diff cmd but is there a way to use Boolean logic? if directory a contents == directory b contents ...
1 vote
3 answers
92 views

diff: Find files that differ and are in the second directory

Say that I have these files for example: old/common-change/index.html new/common-change/index.html new/only-new/index.html old/only-old/index.html The output of diff -qr is close to what I want: $ ...
5 votes
2 answers
427 views

diff program gives false positive for files with non-ASCII characters in filename

Example: % diff "/Volumes/New Volume/4kyoutube/" "/Volumes/New Volume/tmpmusic"| grep Distortion Only in /Volumes/New Volume/tmpmusic: ZAC & Bäkka - Distortion (Original Mix) [...
0 votes
1 answer
84 views

A printf format for "find" or a means to control diff in comparing files across file systems

Working from home, the contents of my laptop undergoes a lot of changes. Before lockdown, I was usually in the office, and I could manually mirror files to a network drive. Working from home means no ...
0 votes
1 answer
81 views

How to create a directory tree with only the changed files of two source directory trees

I have two directory trees (actually macOS volumes) with similar files and want to create a third directory tree containing only the files which are changed between the two source trees. How can I do ...
  • 489
0 votes
1 answer
59 views

Relaxing cmp conditions on diff

Is there a independent diff tool that ignores differences as long as they're only related to row ordering and not content? For example, a.txt: aa bb and b.txt: bb aa should be identical, since they ...
  • 965
1 vote
0 answers
40 views

Unexpected result from diff

Isn't the output contradictory? diff reports that the file is only in one of the locations. But then when I check with ls, the file is there. What is the reason? Is it because the filename contains ...
0 votes
0 answers
151 views

Diff says that files differ after copying them with cp -a

I have a flash drive which I backed up onto a disk with the following command: cp -a /media/user/flashDrive /home/user/Documents/flashBackup Now I just wanted to quickly check if the files were ...
1 vote
2 answers
212 views

`diff` on files without newlines

I need to diff on a file that isn't ASCII and haven't newlines. I want ideally to see what is new, what is deleted, what is modified, and maybe see the proportion (percentage, size) who is different ...
  • 25
0 votes
1 answer
84 views

How to keep file names when using diff with regex

I am using this diff to show whether two files differ, but I need the regex to ignore the lines that are different that I don't care about. But the way it is set up it changes the names of the files ...
0 votes
1 answer
379 views

diff with or without --brief

When comparing the file contents of two directories using diff dirA dirB, what are the differences between with or without the --brief option? As far as I notice, by default diff reports only when ...
  • 275
0 votes
1 answer
107 views

Can diff change the root path name in its output for patch files?

You constantly see kernel patches where it's a/subdir/file.c b/subdir/file.c. Say in reality you have linux-5.10.37_org and linux-5.10.37_mod, is there a way to get the a and b output without having ...
0 votes
1 answer
376 views

How to diff folders and get verbose information?

I have 2 ~55 Gb folders (with many subfolders) that contain more than 1500 files per ~30 Mb. I need to compare them and get information if some files are missing / new files persist or their hash is ...
  • 37
1 vote
2 answers
794 views

Show differences in strings

This answer shows how to diff two strings - Using the diff command to compare two strings? I try: diff <( printf '%s\n' "tring1" ) <( printf '%s\n' "string2" ) The output is:...
  • 913
-2 votes
1 answer
76 views

How to show colred red green diff patch?

I already generated a diff patch between 2 files: diff file1 file2 > file3 Does there a way to display properly the file3 path, in a colored way. cat file3 do the job but there's no colors.
1 vote
3 answers
190 views

How to get the difference between files

I've found other links on the stackoverflow communities that were similar but they didn't answer my question exactly. I have 2 files with a different number of lines BUT I have them both sorted. My ...
-3 votes
1 answer
495 views

Difference between diff and sum utilities

We use diff for finding difference between two files. We use checksum utilities for finding hashes and compare them later. In this regards, I have some questions : Can we diff any type of file ? For ...
1 vote
3 answers
1k views

How to create a patch for renaming a file

Suppose I have a file (myfile.txt) containing this text: The quick brown fox jumps over the lazy dog. I rename this file from myfile.txt to mystory.txt. How do I create a diff that represents this ...
  • 2,334
0 votes
3 answers
139 views

tree command: Can you prevent the formatting dependancy on the final item?

I am using tree and diff to compare a local directory with a USB backup version of the same directory, and to identify noteworthy / discardable differences. $ cd home/dir/ $ tree --charset=ascii -af . ...
1 vote
1 answer
1k views

How to ignore timestamp of the files while performing diff operation

I created a file named me.txt with text This is dummy text Then I made a TAR out of it and named me.txt.tar. Now after a minute I again created a file with exactly same name and the text (basically I ...
0 votes
2 answers
141 views

How to compare two tsv extract in Unix and print differences with key and header?

I have two files with same header and structure and the first column is a key. File 1: key val1 val2 val3 val4 val5 Item1 10 12 44 88 22 Item2 33 33 43 77 22 Item3 28 44 55 ...
0 votes
2 answers
98 views

get only the unmatched list as an output

I want to know on which ports of firewalls from a particular customer the MAC Address Filtering is not active. So I have created 2 files: all.txt contains a list of all firewalls of a customer and ...

1
2 3 4 5
11