I feel this question has been asked before but I am having trouble locating an answer and it combinations of possibilities is mind boggling. Many resources provide something almost close but I'm having trouble getting the expressions in grep correct for my issue.

I am creating a wordlist using crunch with alphanumeric output:

crunch 8 8 ABCDEFGHIJKLMNOPQRSTUVWXYZ + 1234567890 -t %@%@%@%@

This will output 8 alphanumeric strings with an alpha and a number like so:


I have been trying to pipe the output to grep where the final result will omit output with any character in any pattern repeats. Due to the nature of the crunch output, consecutive repeats are already eliminated. Is there a correct expression to omit the non consecutive ones? Or is there a possible way to do this with just crunch?

1A1A1A1A1A not output
1A1A21B2A3 not output
1A1A31A1A3 not output

acceptable output:


Any help with trying to understand the expressions in this regard is greatly appreciated.


With back-references:

grep -v '\(.\).*\1'

-v is to reverse (print the lines that don't match), and the regexp is \(.\) any single character captured, followed by any number of characters (.*) followed by the same character \1 captured earlier.

  • Ah! I've been trying to set up grep with -E rather than -v. This is working. Many thanks for your help! – Remembermyname Jan 3 '20 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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