Tag Info

New answers tagged

0

diff might not be the right tool. It sounds like you need to use comm, which classifies each line as being in one file, the other file, or common to both. The key limitation, though, is that comm requires both input files to be sorted


1

use grep option to filter out line from file $ diff f1 f2 3c3 < I need to wash the dog. --- > I need to wash the car. $ diff <( grep -v -f f3 -x f1) <( grep -v -f f3 -x f2) 3d2 < I need to wash the dog. where <( ) is a bash syntax to create a temporary file in grep -x match whole lie -f f3 take patterm from file f3 -v show unmatched ...


3

A workaround would be to strip of the corresponding lines and then diff it. That's to say, both file1 and file2 would look like: I need to buy apples. I need to run the laundry. I need to get the car detailed. You can do this using a combination of grep, perl and sed: $ lines_to_ignore=$(grep -nFf file3 file2 | perl -pe 's|^(\d+):.*|$1s/.//g;|') $ echo ...


1

You could combine diff and combine here: $ diff file1.txt <(combine file2.txt NOT file3.txt) 3d2 < I need to wash the dog. Updated to reflect changes in OP.


2

This does the comparison from the perspective of fileA: $ awk 'FNR==NR{a[NR]=$0;next;} $0!=a[FNR]' fileB fileA this is a string empty string This approach reads the whole of fileB into memory. Thus, if your files are huge (too big for memory), you should choose another approach. Similarly, to obtain the output from the perspective of fileB: $ awk ...


0

To create a list of new or modified files programmatically the best solution I could come up with is using rsync, sort, and uniq: (rsync -rcn --out-format="%n" old/ new/ && rsync -rcn --out-format="%n" new/ old/) | sort | uniq Let me explain with this example: we want to compare two dokuwiki releases to see which files were changed and which ones ...



Top 50 recent answers are included