Shell Hacks

Complex and inefficient shell snippets? Sign me up!

Here’s my version:

dselect update
cat /var/lib/dpkg/available | sed -n 'p;s/^.//p' | sed 's/../&\
/g' | tr A-Z a-z | grep '[a-z][a-z]' | sort | uniq -u

It doesn’t quite match the original — having the letter pair appear twice for a single package will disqualify it, rather than disqualification only happen when it appears in two packages, and it probably looks at more text than it should (like field names as well as contents). On the other hand, it’s a damn sight quicker (O(n*lg(n) time, O(n) space, where n is the size of your available file), and it includes sed fun.

Leave a Reply