From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Thu, 12 Mar 2015 09:46:31 -0700 To: 9fans@9fans.net Message-ID: <8f07dd60b7c8ad5c85e3b6ed8ac18a37@brasstown.quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: [9fans] fun with rc Topicbox-Message-UUID: 49560fc4-ead9-11e9-9d60-3106f5b1d025 so an interesting problem i run into from time to time is separately comp= uting 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 thi= s easily, but that seems dull and tedious. but as it turns out, one can compute the deleted and added files relative= ly efficiently with diff in two steps. obviously uniq -d gives us the union= , so fn =E2=88=A9 {echo $$1 $$2 | sed 's/ /\n/g' | sort | uniq -d} and uniq -u gives us not union fn not=E2=88=A9 {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=3D`{=E2=88=A9 $1 $2} not=E2=88=A9 c $1} so then echo 'added=3D(' `{listminus old new} ')' echo 'deleted=3D(' `{listminus new old} ')' he! such fun with rc. this is available now in 9atom. - erik