diff bin/intersection @ 88:464d2dfb99c9

new
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 13 Apr 2021 17:02:09 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/intersection	Tue Apr 13 17:02:09 2021 +0000
@@ -0,0 +1,19 @@
+#!/bin/sh
+# Output intersection (or, with -d, difference) of two files, line by line
+# No detection or special treatment of duplicates
+# Usage: intersection [-d] s1 s2
+# In the case of difference, which is ordered, interpretation is s1 - s2
+if [ "$1" = "-?" ]
+ then
+   echo "Usage: intersection [-d] s1 s2"
+   exit 1
+fi
+if [ "$1" = "-d" ]
+ then
+  shift
+  fgrep -x -v -f "$2" "$1"
+ else
+  fgrep -x -f "$1" "$2"
+  exit 0
+fi
+