annotate bin/intersection @ 175:d123ef7fdb82
working on implementing types and parts:
1, 2, 4 working, 3 not
| author |
Henry S. Thompson <ht@inf.ed.ac.uk> |
| date |
Mon, 03 Jul 2023 18:16:14 +0100 |
| parents |
464d2dfb99c9 |
| children |
|
| rev |
line source |
|
88
|
1 #!/bin/sh
|
|
|
2 # Output intersection (or, with -d, difference) of two files, line by line
|
|
|
3 # No detection or special treatment of duplicates
|
|
|
4 # Usage: intersection [-d] s1 s2
|
|
|
5 # In the case of difference, which is ordered, interpretation is s1 - s2
|
|
|
6 if [ "$1" = "-?" ]
|
|
|
7 then
|
|
|
8 echo "Usage: intersection [-d] s1 s2"
|
|
|
9 exit 1
|
|
|
10 fi
|
|
|
11 if [ "$1" = "-d" ]
|
|
|
12 then
|
|
|
13 shift
|
|
|
14 fgrep -x -v -f "$2" "$1"
|
|
|
15 else
|
|
|
16 fgrep -x -f "$1" "$2"
|
|
|
17 exit 0
|
|
|
18 fi
|
|
|
19
|