$ grep -E '(.).*\1.*:' 1056884.out | tail -n1 aeiprsst: 279 $ grep -E '^[aeiprsst]{1,8}$' 2of12inf.txt | grep -Ev '([aeiprt]).*\1|s.*s.*s' | wc -l 279