I recently had a curiosity about words in the dictionary that share both "pro-" and "con-" as a prefix. So, for example, procession/concession, produce/conduce, profess/confess, progress/congress, and so on. I'm basically looking for any words that match both ^pro(.+)$ and ^con(.+)$, where the content of the capture group is the same.
My initial caveman command was:
sed -nr 's/^con(.+)$/\1/Ip' /usr/share/dict/words | \
xargs -I SUFFIX -n1 grep -i '^proSUFFIX$' /usr/share/dict/words
It seems to work, outputting a full "con-" word as long as there exists a matching "pro-" word. Problem is, it's slooow. It invokes grep for every potential match, asking it to scan the whole dictionary each time. I could speed it up by making a temporary file that only has pro/con words in it, but it feels like there must be some efficient way to do this without writing a file.
Is there a tool in the GNU world that's well suited to this kind of intersection search?

egrep '^(pro|con).*' /usr/share/dict/wordsmight do the trick as a starting point, perhaps. You could then put the resultant list through ased,awk, orgrepmeatgrinder that only keeps paired words.egrep '^(pro|con).* /usr/share/dict/words | sed 's/^...//' | sort | uniq -dwill give you a list of all the word-bases that have both aproandconprefix!uniq -d! very nice.