view bin/intersection @ 155:58b90cd52c15

for 2022 exercise
author Henry Thompson <ht@markup.co.uk>
date Fri, 01 Jul 2022 17:50:06 +0200
parents 464d2dfb99c9
children
line wrap: on
line source

#!/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