Friday, June 27, 2014

Re: Compare files, save differences

You can use the `diff` program to check differences between files. You
could also use `git diff` as an alternative. If you want to view changes
interactively in vim use `:vimdiff`. Seek help for these commands in the
man pages and `:help` documentation.

- Conner


On Fri, Jun 27, 2014 at 01:28:33AM -0400, kamaraju kusumanchi wrote:
>On Mon, Apr 21, 2014 at 5:14 AM, Jeri Raye <jeri.raye@gmail.com> wrote:
>
>> Hi,
>>
>> I have a file allwords.txt.
>> And I have another file mywords.txt
>>
>> How can I filter the differences, and safe them in another file called
>> difwords.txt?
>>
>> Example:
>> +------ allwords.txt -------+
>> James
>> Richard
>> Anna
>> Claude
>> Ben
>> +------------+
>>
>> +------mywords.txt-----+
>> Anna
>> Ben
>> +-------------------+
>>
>> This should then make the following file
>>
>> +------difwords.txt-----+
>> James
>> Richard
>> Claude
>> +-----------+
>>
>
>It has been a long time since you posted this. I am not sure if you found
>the solution already. But since this is a problem I frequently encounter, I
>made a perl script to solve it. You can download it from
>https://sourceforge.net/p/rajuutils/code/ci/master/tree/perl/overlap/ . By
>default, it operates on two files setA.txt, setB.txt. The output is stored
>in "out" directory.
>
>For example, with the following input files
>
>rajulocal@hogwarts:~/work/rutils/perl/overlap$ cat setA.txt
>James
>Richard
>Anna
>Claude
>Ben
>rajulocal@hogwarts:~/work/rutils/perl/overlap$ cat setB.txt
>Anna
>Ben
>Jeff
>Raju
>
>Run the script
>
>rajulocal@hogwarts:~/work/rutils/perl/overlap$ ./overlap.pl
>set count pct
>A 5 0.71
>B 4 0.57
>A or B 7 1.00
>A and B 2 0.29
>A - B 3 0.43
>B - A 2 0.29
>notA and notB 0 0.00
>storing output files under out directory
>
>The output files are as follows:
>rajulocal@hogwarts:~/work/rutils/perl/overlap$ ls out/
>out_AandB.txt out_AorB.txt out_notAnotB.txt out_onlyA.txt out_onlyB.txt
>
>In this case, the file you are interested in is out_onlyA.txt
>
>rajulocal@hogwarts:~/work/rutils/perl/overlap$ cat out/out_onlyA.txt
>Claude
>James
>Richard
>
>hth
>raju
>--
>Kamaraju S. Kusumanchi
>http://malayamaarutham.blogspot.com/
>
>--
>--
>You received this message from the "vim_use" maillist.
>Do not top-post! Type your reply below the text you are replying to.
>For more information, visit http://www.vim.org/maillist.php
>
>---
>You received this message because you are subscribed to the Google Groups "vim_use" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment