#!/bin/bash ## form the intersection of 2 files; Eugene Reimer 2010-04; ## for files that are set-like / uniquified, but need not be sorted (for sorted files using join or comm may be slightly faster): ## see also: SetUnion SetSubtract; ## ## These and other useful one-liners are found in: http://www.pixelbeat.org/cmdline.html ## SetUnion: sort "$1" "$2" |uniq ## SetIntersection: sort "$1" "$2" |uniq -d ## SetSubtract: sort "$1" "$2" "$2" |uniq -u ##note: his SetDifference has $1, $2 reversed to my way of thinking sort "$1" "$2" |uniq -d