comparison 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
comparison
equal deleted inserted replaced
87:b6a5999d8e06 88:464d2dfb99c9
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