Tag Info

New answers tagged

1

Yes, this is a good way to create a patch. In short: To create patch for single file your command may look like diff -Naru file_original file_updated > file.patch where -N: treat absent files as empty -a: treat all files as text -r: recursively compare any subdirectories found -u: output NUM (default 3) lines of unified context To create patch for ...


1

My math might be a bit off, but I beleive you asked for a ratio, and I beleive this produces a ratio. #!/usr/bin/env bash # File 1 contains 1,2,3,4,5 on new lines # File 2 contains 1,2,3,4,5,6,7,8,9,10 on new lines. # Compare differentials side-by-side diff -y 1 2 > diff # Print lines to file which do not contain ">" prefix. sed 's/[ ]/d' diff > ...


5

There's a tool called diffstat that sounds like what you're looking for. $ diff <file1> <file2> | diffstat Example $ diff afpuri.c afpuri1.c | diffstat unknown | 53 ++++++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 33 deletions(-) This can be used for diff output which includes multiple files in a ...


0

awk 'FNR==NR{old[$0];next};!($0 in old)' old.txt new.txt


3

If doing the comparision line-by-line is acceptable, then the following will tell which lines are duplicated in file text and how many times each one appears: sort text | uniq -c | grep -vE '^\s*1 ' As an example, $ cat text alpha beta alpha gamma alpha beta $ sort text | uniq -c | grep -vE '^\s*1 ' 3 alpha 2 beta Using the usual unix ...


8

comm is your friend: NAME comm - compare two sorted files line by line SYNOPSIS comm [OPTION]... FILE1 FILE2 DESCRIPTION Compare sorted files FILE1 and FILE2 line by line. With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and ...


16

You can use grep. Give it the small file as input and tell it to find non-matching lines: grep -vxFf file.txt bigfile.txt > newbigfile.txt The options used are: -F, --fixed-strings Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by POSIX.) ...


1

This explanation seems to make more sense then the above 2 that you cited. excerpt - https://www.gnu.org/software/diffutils/manual/html_node/diff-Performance.html Normally diff discards the prefix and suffix that is common to both files before it attempts to find a minimal set of differences. This makes diff run faster, but occasionally it may ...


1

If you want to compare two directories with files and subdirectories, then the diff command can do that for you. By running diff -rq /path/to/fileset1 /path/to/fileset2, it will tell you which files differ and which are where missing for which tree. You could even extend the command give a detailed list of all the changes for auditing purposes with diff ...


3

As I understand your question you want to find out whether N random files differ between two file system paths. Comparing the files should be faster than calculating checksums of both files. Here is how you can do it: #!/bin/sh list1=/tmp/list1 list2=/tmp/list2 shuflist=/tmp/shuflist n=100000 # How many files to compare. if test ! -d "$1" -o ! -d "$2"; then ...



Top 50 recent answers are included