annotate bin/intersection @ 95:32c1c853062f

(none)
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Fri, 16 Apr 2021 09:00:17 +0000
parents 464d2dfb99c9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
1 #!/bin/sh
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
2 # Output intersection (or, with -d, difference) of two files, line by line
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
3 # No detection or special treatment of duplicates
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
4 # Usage: intersection [-d] s1 s2
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
5 # In the case of difference, which is ordered, interpretation is s1 - s2
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
6 if [ "$1" = "-?" ]
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
7 then
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
8 echo "Usage: intersection [-d] s1 s2"
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
9 exit 1
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
10 fi
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
11 if [ "$1" = "-d" ]
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
12 then
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
13 shift
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
14 fgrep -x -v -f "$2" "$1"
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
15 else
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
16 fgrep -x -f "$1" "$2"
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
17 exit 0
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
18 fi
Henry S. Thompson <ht@inf.ed.ac.uk>
parents:
diff changeset
19