Numeric output and dont echo repeating numbers for ex 1010101; 2020202, 1212121
<p>Looking for a script that can pipe or print to file and generate a random, non repeating output wordlist/numberlist [crunch for example can do that with the -d option but 10101 etc dont get sorted out]. </p>

<p>Example:  a numeric list <code>000000-999999</code> and written to a file / pipe to program all numbers but no repeating sequences like <code>1010101; 2020202; 12121212, 13131313 ......</code> or repeating numbers <code>11 222 3333 44444 .....</code></p>

<p>EDIT:</p>

<p>Great answers so far, thank you.</p>

<p>Heres a little hack that does pretty much what is intented, but not perfectly.
Looking for a solution to have the result directly, going through the answers asap.</p>

<pre><code>sed -i  -e '/1010/d' -e '/1212/d' file.txt
</code></pre>

<p>Source:
<a href="http://stackoverflow.com/questions/5410757/delete-lines-in-a-text-file-that-containing-a-specific-string">Delete lines in a text file that containing a specific string</a></p>

<p>Here's a potential, simple solution for the specific six digit range, 000000-999999, you requested:</p>

<pre><code>from regex import match
from random import sample

DIGITS = 6

assert (DIGITS % 2 == 0), "Only works for even digit string lengths"

number_format = "{:0" + str(DIGITS) + "d}"

for number in sample(range(10**DIGITS), 10**DIGITS):

    string = number_format.format(number)

    if match(r"^(.+)\1+$", string) is None:

        print(string)
</code></pre>

<p>The repetition examples you gave were for seven and eight digit numbers.  In odd length numeric strings it would be tricker to detect the final one in <code>1010101</code> as a partial match.  Only even length numeric strings can be done with the above thus the <code>assert</code>.</p>

python bash perl random sequence