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}

and uniq -u gives us not union

        fn not∩ {echo $$1 $$2 | sed 's/ /\n/g' | sort | uniq -u}

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} ')'

he!  such fun with rc.

this is available now in 9atom.

- erik

Reply via email to