diff

difference between the content of two files

谁说我不能喝 提交于 2019-11-27 22:27:40
I have two files one file subset of other and i want to obtain a file which has contents not common to both.for example File1 apple mango banana orange jackfruit cherry grapes eggplant okra cabbage File2 apple banana cherry eggplant cabbage The resultant file, difference of above two files mango orange jackfruit grapes okra Any ideas on this are appreciated. use awk, no sorting necessary (reduce overheads) $ awk 'FNR==NR{f[$1];next}(!($1 in f)) ' file2 file mango orange jackfruit grapes okra You can sort the files then use comm : $ comm -23 <(sort file1.txt) <(sort file2.txt) grapes jackfruit

Myers diff algorithm vs Hunt–McIlroy algorithm

拈花ヽ惹草 提交于 2019-11-27 21:40:23
The longest common subsequence problem is a classic computer science problem, algorithms to solve it are the root of version control systems and wiki engines. Two basic algorithms are the Hunt–McIlroy algorithm which was used to create the original version of diff , and the Myers diff algorithm which is used by the GNU diff utility currently. Both seem to work more or less by finding the shortest path through a graph that represents the edit space between the two strings or text files. The edit space is the number of inserts or deletes necessary to transform one sequence into the other. So

diff two big files in Python

冷暖自知 提交于 2019-11-27 21:40:14
I have two big text files, near 2GB each. I need something like diff f1.txt f2.txt . Is there any way to do this task fast in python? Standard difflib is too slow. I assume there is faster way, because difflib is fully implemented in Python. How about using difflib in way that you script can handle big files? Don't load the files in memory, but iterate through the files of the files and diff in chunks. For e.g 100 lines at a time. import difflib d = difflib.Differ() f1 = open('bigfile1') f2 = open('bigfile2') b1 = [] b2 = [] for n, lines in enumerate(zip(f1,f2)): if not (n % 100 == 0): b1

compare object properties and show diff in PHP

瘦欲@ 提交于 2019-11-27 21:20:30
I'm searching for a way to show me the different properties/values from given objects... $obj1 = new StdClass; $obj1->prop = 1; $obj2 = new StdClass; $obj2->prop = 2; var_dump(array_diff((array)$obj1, (array)$obj2)); //output array(1) { ["prop"]=> int(1) } This works very well as long the property is not a object or array. $obj1 = new StdClass; $obj1->prop = array(1,2); $obj2 = new StdClass; $obj2->prop = array(1,3); var_dump(array_diff((array)$obj1, (array)$obj2)) // Output array(0) { } // Expected output - array { ["prop"]=> array { [1]=> int(2) } } Is there a way to get rid of this, even

Is there a way to ask git diff to show the method name instead of the class name?

China☆狼群 提交于 2019-11-27 21:14:16
This has been bugging me for a while and searching has yielded no hints. Issue: When I do a git diff on a PHP file containing a Class , each hunk description has the class name with no mention of the method name. For example: @@ -351,7 +351,7 @@ class Session $form->setError($field, $subpassValid['msg']); } // E-Mail address error checking $field = "email"; //Use field name for email - if(!isset($subemail) || strlen($subemail = trim($subemail)) == 0){ + if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); @@ -373,7 +373,7 @@ class Session

Large github commit diff not shown

谁说我不能喝 提交于 2019-11-27 20:24:19
This happens to me both with Compare view as well as standard commits that are large in the amount of files changed. The screenshot below is from a compare between two branches with 380 files changed. The files at the beginning of the diff log have their diffs visualized but at a certain point down the page it stops visualizing the diffs. I understand you don't want massive pages but I can't seem to find a way to view a file's diff individually. Instead I have to check these both out locally and do the diff manually. Does anyone have a simpler solution whether it be software driven or

Git diff --stat explanation

好久不见. 提交于 2019-11-27 20:22:50
Git's pull output has been explained here fairly well. In spite of this I'm still unsure exactly what the text graph relates to. For example: git diff --stat master HEAD^ Outputs (truncated): Site/index.php | 118 ++-- While the number of lines modified is clearly displayed as 118, the text graph is a little harder to interpret. Could this relate to the ratio of added and removed lines? Yes it's the ratio of added and removed lines. See also: man diffstat Edgard Leal git diff --numstat "@{1 day ago}" Parameters: diff = Show diff --numstat = show the number of lines inserted and removed @{1 day

(Vim)diff two subroutines in same file

瘦欲@ 提交于 2019-11-27 20:03:56
问题 Is it possible to diff or even vimdiff two almost similar subroutines which occur in the same file? If so, how? I can think of copying the two subroutines in two separate files and then diff them, but is there a way to do it within the original file? Thanks! 回答1: You cannot do this within the original file, but you can do this without using separate files, only separate buffers. This should work if you copied one subroutine in register a (for example, with "ay typed in visual mode) and other

Is there a way to configure vimdiff to ignore ALL whitespaces?

拜拜、爱过 提交于 2019-11-27 20:01:56
问题 I'm using vim -d file1 file2 in order to see the differences between them. This works fine, but I want to ignore whitespace changes - they are irrelevant for source code files. Vim help states that the following command will do the magic: set diffopt+=iwhite But unfortunately, this command only adds -b to diff tool command line, and that only ignores trailing whitespaces. The correct command line key for diff should be -w , to ignore all whitespace changes. But I can't find how to modify the

How to set Araxis as diff / merge tool for MSYS git?

守給你的承諾、 提交于 2019-11-27 19:51:43
I'm trying to use Araxis Merge as my diff / merge tool for MSYSGit. I found a few resources on the net: On the Araxis site , they mention an "easy" way, but it implies a executables (araxisgitdiff.exe and araxisgitmerge.exe) that are not part of my distro. I also found some info in gitguru , but the actual information re: Araxis is sparse at best, and I could not make anything out of that. Finally, there was some info on an older stackoverflow post , but the suggested method doesn't work for me. That particular info was geared towards OS X. I "translated" to Windows as best as I could, but