From: minux <minux.ma@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] fun with rc
Date: Thu, 12 Mar 2015 13:07:34 -0400 [thread overview]
Message-ID: <CA+db=n2n30Qp4v0AzzRJtfEZ+ALEn-R8HLnfNOBhQ6S7bpQiNg@mail.gmail.com> (raw)
In-Reply-To: <8f07dd60b7c8ad5c85e3b6ed8ac18a37@brasstown.quanstro.net>
[-- Attachment #1: Type: text/plain, Size: 1057 bytes --]
On Mar 12, 2015 12:52 PM, "erik quanstrom" <quanstro@quanstro.net> wrote:
> so an interesting problem i run into from time to time is separately
computing
> the files added to and deleted from a directory in a shell script. uniq
doesn't
> work for this. certainly one can loop over two lists of files and do
this easily,
> but that seems dull and tedious.
>
> but as it turns out, one can compute the deleted and added files
relatively
> efficiently with diff in two steps. obviously uniq -d gives us the
union, so
>
> fn ∩ {echo $$1 $$2 | sed 's/ /\n/g' | sort | uniq -d}
Isn't this called (set) intersection?
> and uniq -u gives us not union
>
> fn not∩ {echo $$1 $$2 | sed 's/ /\n/g' | sort | uniq -u}
this is (set) symmetric difference.
> but then we can compuete the "difference" (relative complement) we want
> with
>
> fn listminus {c=`{∩ $1 $2} not∩ c $1}
>
> so then
>
> echo 'added=(' `{listminus old new} ')'
> echo 'deleted=(' `{listminus new old} ')'
>
[-- Attachment #2: Type: text/html, Size: 1437 bytes --]
next prev parent reply other threads:[~2015-03-12 17:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-12 16:46 erik quanstrom
2015-03-12 17:07 ` minux [this message]
2015-03-12 17:17 ` erik quanstrom
2015-03-12 18:09 ` Christian Neukirchen
2015-03-12 18:31 ` erik quanstrom
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+db=n2n30Qp4v0AzzRJtfEZ+ALEn-R8HLnfNOBhQ6S7bpQiNg@mail.gmail.com' \
--to=minux.ma@gmail.com \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).