6 ms·
I don't like using multiple commands. mawk 'BEGIN{b = "[abcdefois]"; l = "[a-z]"; W = "^" b l l l l l "$"}; $0 ~ W {print "#" toupper($0);}' /usr/share/dic
by ratsmack 4y ago
I don't like using multiple commands.
mawk 'BEGIN{b = "[abcdefois]"; l = "[a-z]"; W = "^" b l l l l l "$"}; $0 ~ W {print "#" toupper($0);}' /usr/share/dict/words
- Keyframe 4y agoyou also aren't going to get valid color codes
- kbr2000 4y agoI came up with: gawk 'BEGIN {IGNORECASE=1} ((length($1) == 6) && /^[a-fois]+$/) {gsub(/o/,0);gsub(/i/,1);gsub(/s/,5); print toupper("#"$1)}' /usr/share/dict/words (caveat: it does not filter out duplicates)
- adrianmonk 4y agoYou can also do it entirely in sed: sed -E -e '/^[a-fio]{6}$/!d; y/abcdefioIO/ABCDEF1010/; s/^/#/' /usr/share/dict/words
- xertopertha 4y agoThis produces 35 items. The grep version gives 93
- adrianmonk 4y agoYeah, I failed to make the pattern case insensitive. Here's a fixed version that also handles S/5: sed -E -e '/^[A-FIOSa-fios]{6}$/!d; y/abcdefiosIOS/ABCDEF105105/; s/^/#/' /usr/share/dict/words