delete pattern at least 5 numbers non consecutive

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I have a file with about 7 million passwords with mixed Lower Upper digits



all have the same length 8 symbols



I want to remove the passwords than contain 5 or more digits not necessary consecutive:



Example:



A0s123tf - OK
tttttttt - OK
096545aZ - Remove
Z0123456 - Remove
z445Jz55 - Remove -> fail


if I do for example:



grep -E -v '[0-9]5, myfile 


fail with the last word because the numbers aren't consecutive.



What is the correct regex for this case?










share|improve this question






















  • so.. /(.*[0-9].*)5/?

    – DopeGhoti
    Jan 4 at 20:09











  • grep -E -v '(.*[0-9])5' file or grep -E -v '([0-9].*)5' file should be enough.

    – jimmij
    Jan 4 at 20:11







  • 1





    On a tangential note, someone has done some very bad things if these are actual passwords. They are not hashed, they are shorter than the absolute minimum which should be required these days, and they have a counter-productive format restriction (all of these points have been discussed at great length elsewhere). If this is related to a production system you're working on, you'd better get someone familiar with proper password handling in ASAP. Someone is at least morally, and possibly criminally, negligent.

    – l0b0
    Jan 4 at 20:40
















0















I have a file with about 7 million passwords with mixed Lower Upper digits



all have the same length 8 symbols



I want to remove the passwords than contain 5 or more digits not necessary consecutive:



Example:



A0s123tf - OK
tttttttt - OK
096545aZ - Remove
Z0123456 - Remove
z445Jz55 - Remove -> fail


if I do for example:



grep -E -v '[0-9]5, myfile 


fail with the last word because the numbers aren't consecutive.



What is the correct regex for this case?










share|improve this question






















  • so.. /(.*[0-9].*)5/?

    – DopeGhoti
    Jan 4 at 20:09











  • grep -E -v '(.*[0-9])5' file or grep -E -v '([0-9].*)5' file should be enough.

    – jimmij
    Jan 4 at 20:11







  • 1





    On a tangential note, someone has done some very bad things if these are actual passwords. They are not hashed, they are shorter than the absolute minimum which should be required these days, and they have a counter-productive format restriction (all of these points have been discussed at great length elsewhere). If this is related to a production system you're working on, you'd better get someone familiar with proper password handling in ASAP. Someone is at least morally, and possibly criminally, negligent.

    – l0b0
    Jan 4 at 20:40














0












0








0








I have a file with about 7 million passwords with mixed Lower Upper digits



all have the same length 8 symbols



I want to remove the passwords than contain 5 or more digits not necessary consecutive:



Example:



A0s123tf - OK
tttttttt - OK
096545aZ - Remove
Z0123456 - Remove
z445Jz55 - Remove -> fail


if I do for example:



grep -E -v '[0-9]5, myfile 


fail with the last word because the numbers aren't consecutive.



What is the correct regex for this case?










share|improve this question














I have a file with about 7 million passwords with mixed Lower Upper digits



all have the same length 8 symbols



I want to remove the passwords than contain 5 or more digits not necessary consecutive:



Example:



A0s123tf - OK
tttttttt - OK
096545aZ - Remove
Z0123456 - Remove
z445Jz55 - Remove -> fail


if I do for example:



grep -E -v '[0-9]5, myfile 


fail with the last word because the numbers aren't consecutive.



What is the correct regex for this case?







linux grep regular-expression






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 4 at 20:04









ROTORROTOR

11




11












  • so.. /(.*[0-9].*)5/?

    – DopeGhoti
    Jan 4 at 20:09











  • grep -E -v '(.*[0-9])5' file or grep -E -v '([0-9].*)5' file should be enough.

    – jimmij
    Jan 4 at 20:11







  • 1





    On a tangential note, someone has done some very bad things if these are actual passwords. They are not hashed, they are shorter than the absolute minimum which should be required these days, and they have a counter-productive format restriction (all of these points have been discussed at great length elsewhere). If this is related to a production system you're working on, you'd better get someone familiar with proper password handling in ASAP. Someone is at least morally, and possibly criminally, negligent.

    – l0b0
    Jan 4 at 20:40


















  • so.. /(.*[0-9].*)5/?

    – DopeGhoti
    Jan 4 at 20:09











  • grep -E -v '(.*[0-9])5' file or grep -E -v '([0-9].*)5' file should be enough.

    – jimmij
    Jan 4 at 20:11







  • 1





    On a tangential note, someone has done some very bad things if these are actual passwords. They are not hashed, they are shorter than the absolute minimum which should be required these days, and they have a counter-productive format restriction (all of these points have been discussed at great length elsewhere). If this is related to a production system you're working on, you'd better get someone familiar with proper password handling in ASAP. Someone is at least morally, and possibly criminally, negligent.

    – l0b0
    Jan 4 at 20:40

















so.. /(.*[0-9].*)5/?

– DopeGhoti
Jan 4 at 20:09





so.. /(.*[0-9].*)5/?

– DopeGhoti
Jan 4 at 20:09













grep -E -v '(.*[0-9])5' file or grep -E -v '([0-9].*)5' file should be enough.

– jimmij
Jan 4 at 20:11






grep -E -v '(.*[0-9])5' file or grep -E -v '([0-9].*)5' file should be enough.

– jimmij
Jan 4 at 20:11





1




1





On a tangential note, someone has done some very bad things if these are actual passwords. They are not hashed, they are shorter than the absolute minimum which should be required these days, and they have a counter-productive format restriction (all of these points have been discussed at great length elsewhere). If this is related to a production system you're working on, you'd better get someone familiar with proper password handling in ASAP. Someone is at least morally, and possibly criminally, negligent.

– l0b0
Jan 4 at 20:40






On a tangential note, someone has done some very bad things if these are actual passwords. They are not hashed, they are shorter than the absolute minimum which should be required these days, and they have a counter-productive format restriction (all of these points have been discussed at great length elsewhere). If this is related to a production system you're working on, you'd better get someone familiar with proper password handling in ASAP. Someone is at least morally, and possibly criminally, negligent.

– l0b0
Jan 4 at 20:40











2 Answers
2






active

oldest

votes


















1














Do you need it to be a regexp, or can you pipe? A hacky way to do it would be to look for 5 digits



$ cat j
A0s123tf
tttttttt
096545aZ
Z0123456
z445Jz55
$ grep -E -v 'd.*d.*d.*d.*d' j
A0s123tf
tttttttt
$





share|improve this answer






























    1














    Alternatively, search for the inverse; since they're each eight characters long, require 4 non-digits:



    grep -E '[^[:digit:]].*[^[:digit:]].*[^[:digit:]].*[^[:digit:]]' myfile


    or condensed a bit:



    grep -E '([^[:digit:]].*)4' myfile





    share|improve this answer























    • Running some timing tests on 7 million randomly generated 8-char passwords, I'm getting around 7.7 sec for the 4 * not-a-digit search, and around 6.5 sec for 5 * is-a-digit search. Couldn't tell you why, though.

      – mmusante
      Jan 4 at 20:29










    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492570%2fdelete-pattern-at-least-5-numbers-non-consecutive%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Do you need it to be a regexp, or can you pipe? A hacky way to do it would be to look for 5 digits



    $ cat j
    A0s123tf
    tttttttt
    096545aZ
    Z0123456
    z445Jz55
    $ grep -E -v 'd.*d.*d.*d.*d' j
    A0s123tf
    tttttttt
    $





    share|improve this answer



























      1














      Do you need it to be a regexp, or can you pipe? A hacky way to do it would be to look for 5 digits



      $ cat j
      A0s123tf
      tttttttt
      096545aZ
      Z0123456
      z445Jz55
      $ grep -E -v 'd.*d.*d.*d.*d' j
      A0s123tf
      tttttttt
      $





      share|improve this answer

























        1












        1








        1







        Do you need it to be a regexp, or can you pipe? A hacky way to do it would be to look for 5 digits



        $ cat j
        A0s123tf
        tttttttt
        096545aZ
        Z0123456
        z445Jz55
        $ grep -E -v 'd.*d.*d.*d.*d' j
        A0s123tf
        tttttttt
        $





        share|improve this answer













        Do you need it to be a regexp, or can you pipe? A hacky way to do it would be to look for 5 digits



        $ cat j
        A0s123tf
        tttttttt
        096545aZ
        Z0123456
        z445Jz55
        $ grep -E -v 'd.*d.*d.*d.*d' j
        A0s123tf
        tttttttt
        $






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 4 at 20:12









        mmusantemmusante

        60736




        60736























            1














            Alternatively, search for the inverse; since they're each eight characters long, require 4 non-digits:



            grep -E '[^[:digit:]].*[^[:digit:]].*[^[:digit:]].*[^[:digit:]]' myfile


            or condensed a bit:



            grep -E '([^[:digit:]].*)4' myfile





            share|improve this answer























            • Running some timing tests on 7 million randomly generated 8-char passwords, I'm getting around 7.7 sec for the 4 * not-a-digit search, and around 6.5 sec for 5 * is-a-digit search. Couldn't tell you why, though.

              – mmusante
              Jan 4 at 20:29















            1














            Alternatively, search for the inverse; since they're each eight characters long, require 4 non-digits:



            grep -E '[^[:digit:]].*[^[:digit:]].*[^[:digit:]].*[^[:digit:]]' myfile


            or condensed a bit:



            grep -E '([^[:digit:]].*)4' myfile





            share|improve this answer























            • Running some timing tests on 7 million randomly generated 8-char passwords, I'm getting around 7.7 sec for the 4 * not-a-digit search, and around 6.5 sec for 5 * is-a-digit search. Couldn't tell you why, though.

              – mmusante
              Jan 4 at 20:29













            1












            1








            1







            Alternatively, search for the inverse; since they're each eight characters long, require 4 non-digits:



            grep -E '[^[:digit:]].*[^[:digit:]].*[^[:digit:]].*[^[:digit:]]' myfile


            or condensed a bit:



            grep -E '([^[:digit:]].*)4' myfile





            share|improve this answer













            Alternatively, search for the inverse; since they're each eight characters long, require 4 non-digits:



            grep -E '[^[:digit:]].*[^[:digit:]].*[^[:digit:]].*[^[:digit:]]' myfile


            or condensed a bit:



            grep -E '([^[:digit:]].*)4' myfile






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 4 at 20:17









            Jeff SchallerJeff Schaller

            39.5k1054126




            39.5k1054126












            • Running some timing tests on 7 million randomly generated 8-char passwords, I'm getting around 7.7 sec for the 4 * not-a-digit search, and around 6.5 sec for 5 * is-a-digit search. Couldn't tell you why, though.

              – mmusante
              Jan 4 at 20:29

















            • Running some timing tests on 7 million randomly generated 8-char passwords, I'm getting around 7.7 sec for the 4 * not-a-digit search, and around 6.5 sec for 5 * is-a-digit search. Couldn't tell you why, though.

              – mmusante
              Jan 4 at 20:29
















            Running some timing tests on 7 million randomly generated 8-char passwords, I'm getting around 7.7 sec for the 4 * not-a-digit search, and around 6.5 sec for 5 * is-a-digit search. Couldn't tell you why, though.

            – mmusante
            Jan 4 at 20:29





            Running some timing tests on 7 million randomly generated 8-char passwords, I'm getting around 7.7 sec for the 4 * not-a-digit search, and around 6.5 sec for 5 * is-a-digit search. Couldn't tell you why, though.

            – mmusante
            Jan 4 at 20:29

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f492570%2fdelete-pattern-at-least-5-numbers-non-consecutive%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay