Monday, April 21, 2014

Re: Compare files, save differences

Hi Jeri!

On Mo, 21 Apr 2014, Jeri Raye 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
> +-----------+

That is what external commands are good for. I would use comm(1)

#v+
/tmp/compare % comm -23 <(sort allwords.txt) <(sort mywords.txt)
Claude
James
Richard
/tmp/compare %
#v-

Best,
Christian
--
Nicht die Frau, die Kinder binden den wagenden Mut, weil wohl jene mit
uns tragen kann, da sie sich mit uns entschließt, diese aber noch
keine Kräfte zum Entschließen und Tragen haben.
-- Jean Paul

--
--
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