Article 5CQZC SED with back-references

SED with back-references

by
danielbmartin
from LinuxQuestions.org on (#5CQZC)
This is a learning exercise.

Have: a large file of English words, one word on each line.

Want: a subset of the file where all words
meet these criteria ...
(1) have 6 letters
(2) letters 1 and 3 are the same
(3) no letters are repeated other than 1 and 3

This sed ...
Code:sed -nr "/^(.)(.)\1([^\1\2])([^\1\2\4])([^\1\2\4\5])$/p" \
<$WordList >$OutFile.. produces a file which contains words such as ...
Code:abacus
alarms
amazon
analog
apathy... which fit the criteria ...

... but also contains words such as ...
Code:avatar
acacia
bubble
cicada
cyclic... which do not fit criterion #3.

Please advise.

Daniel B. Martin

.latest?d=yIl2AUoC8zA latest?i=cLOUhu3REOI:wt2H2cSFQUA:F7zBnMy latest?i=cLOUhu3REOI:wt2H2cSFQUA:V_sGLiP latest?d=qj6IDK7rITs latest?i=cLOUhu3REOI:wt2H2cSFQUA:gIN9vFwcLOUhu3REOI
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments