delete pattern at least 5 numbers non consecutive
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
New contributor
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
New contributor
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
so../(.*[0-9].*){5}/?
– DopeGhoti
2 days ago
grep -E -v '(.*[0-9]){5}' fileorgrep -E -v '([0-9].*){5}' fileshould be enough.
– jimmij
2 days ago
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
2 days ago
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
New contributor
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
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
New contributor
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 days ago
ROTOR
11
11
New contributor
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
ROTOR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
so../(.*[0-9].*){5}/?
– DopeGhoti
2 days ago
grep -E -v '(.*[0-9]){5}' fileorgrep -E -v '([0-9].*){5}' fileshould be enough.
– jimmij
2 days ago
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
2 days ago
add a comment |
so../(.*[0-9].*){5}/?
– DopeGhoti
2 days ago
grep -E -v '(.*[0-9]){5}' fileorgrep -E -v '([0-9].*){5}' fileshould be enough.
– jimmij
2 days ago
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
2 days ago
so..
/(.*[0-9].*){5}/?– DopeGhoti
2 days ago
so..
/(.*[0-9].*){5}/?– DopeGhoti
2 days ago
grep -E -v '(.*[0-9]){5}' file or grep -E -v '([0-9].*){5}' file should be enough.– jimmij
2 days ago
grep -E -v '(.*[0-9]){5}' file or grep -E -v '([0-9].*){5}' file should be enough.– jimmij
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
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
});
}
});
ROTOR is a new contributor. Be nice, and check out our Code of Conduct.
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 2 days ago
mmusante
60735
60735
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
2 days ago
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
2 days ago
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 2 days ago
Jeff Schaller
39k1053125
39k1053125
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
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
add a comment |
ROTOR is a new contributor. Be nice, and check out our Code of Conduct.
ROTOR is a new contributor. Be nice, and check out our Code of Conduct.
ROTOR is a new contributor. Be nice, and check out our Code of Conduct.
ROTOR is a new contributor. Be nice, and check out our Code of Conduct.
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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
2 days ago
grep -E -v '(.*[0-9]){5}' fileorgrep -E -v '([0-9].*){5}' fileshould be enough.– jimmij
2 days ago
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
2 days ago