Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Another one I can't seem to solve : all greek letters with 5 unique letters (meaning that each letter only appears once).

my solution :

egrep '(.)([^/1])([^/1/2])([^/1/2/3])([^/1/2/3/4])' greek.txt

So What I think I am saying :

  • match any first character

  • every consecutive character can't be any of the previous patterns

But what comes out :


Alpha, gamma, they have characters that are not unique. Any hints or tips on what I am doing wrong ?

share|improve this question

2 Answers 2

  • Use one grep to filter all lines with length != 5.
  • Use the second grep to filter all words, where any character repeats.

egrep '^.{5}$' greek.txt | egrep -v '^.*(.).*\1.*$'

Thanks to @StephaneChazelas for pointing out optimizations in a comment:

grep -x '.\{5\}' | grep -v '\(.\).*\1'

share|improve this answer
Note that egrep is not required to support backreferences (traditional implementations don't). grep is. So grep -x '.\{5\}' | grep -v '\(.\).*\1' – Stéphane Chazelas Aug 17 at 12:55

I think you're on the right track but got your slashes going to wrong direction to be back-references. Use \1 not /1!

share|improve this answer
indeed, backrefs are \1 and not /1 – Goez Aug 8 '11 at 12:44
still not working unfortunately :( – Lucas Kauffman Aug 8 '11 at 13:24
I'll have a look when I get home... – Goez Aug 8 '11 at 13:41
[^\1] is any character but backslash and 1. You can't use back references like that (egrep is not meant to support backreferences at all anyway) – Stéphane Chazelas Aug 17 at 13:00
@StéphaneChazelas : I only ever remember seeing egrep implemented as a wrapper script for 'grep -E', and was not aware, that it isn't supposed to support backreferences. OP had used egrep, so I just went with that. – Alex Stragies Aug 17 at 18:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.