delete pattern at least 5 numbers non consecutive
Clash Royale CLAN TAG#URR8PPP
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
add a comment |
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
so../(.*[0-9].*)5/
?
– DopeGhoti
Jan 4 at 20:09
grep -E -v '(.*[0-9])5' file
orgrep -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
add a comment |
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
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
linux grep regular-expression
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
orgrep -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
add a comment |
so../(.*[0-9].*)5/
?
– DopeGhoti
Jan 4 at 20:09
grep -E -v '(.*[0-9])5' file
orgrep -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
add a comment |
2 Answers
2
active
oldest
votes
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
$
add a comment |
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
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
$
add a comment |
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
$
add a comment |
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
$
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
$
answered Jan 4 at 20:12
mmusantemmusante
60736
60736
add a comment |
add a comment |
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
so..
/(.*[0-9].*)5/
?– DopeGhoti
Jan 4 at 20:09
grep -E -v '(.*[0-9])5' file
orgrep -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