Trying to generate random password characters into a file

Multi tool use
up vote
0
down vote
favorite
I want to generate 100
files with 100
random passwords in /mnt/mymnt/passwords
using a script creating some directories.
Even if i try to use cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 30 | head -n 1 > some_random_file.txt
the process just does not stop, anyone has any idea why?
shell scripting password
add a comment |
up vote
0
down vote
favorite
I want to generate 100
files with 100
random passwords in /mnt/mymnt/passwords
using a script creating some directories.
Even if i try to use cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 30 | head -n 1 > some_random_file.txt
the process just does not stop, anyone has any idea why?
shell scripting password
@JeffSchaller uh yeah, fold, sorry and "tr" too
– C. Cristi
Nov 19 at 16:59
@KamilMaciorowski it worked but it stopped inserting passwords after the first file, and I don't get why
– C. Cristi
Nov 19 at 17:10
On a Side note:
Next time Give a try to crunch. That would be much easier than writing a script but If you are into learning rather than achieving some task, writing script is Cool :)
– C0deDaedalus
Nov 20 at 4:00
Using openssl to generate the random value may help. Take a look at "openssl rand -hex 32" for example.
– mrflash818
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to generate 100
files with 100
random passwords in /mnt/mymnt/passwords
using a script creating some directories.
Even if i try to use cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 30 | head -n 1 > some_random_file.txt
the process just does not stop, anyone has any idea why?
shell scripting password
I want to generate 100
files with 100
random passwords in /mnt/mymnt/passwords
using a script creating some directories.
Even if i try to use cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 30 | head -n 1 > some_random_file.txt
the process just does not stop, anyone has any idea why?
shell scripting password
shell scripting password
edited 2 days ago
asked Nov 19 at 16:54


C. Cristi
1647
1647
@JeffSchaller uh yeah, fold, sorry and "tr" too
– C. Cristi
Nov 19 at 16:59
@KamilMaciorowski it worked but it stopped inserting passwords after the first file, and I don't get why
– C. Cristi
Nov 19 at 17:10
On a Side note:
Next time Give a try to crunch. That would be much easier than writing a script but If you are into learning rather than achieving some task, writing script is Cool :)
– C0deDaedalus
Nov 20 at 4:00
Using openssl to generate the random value may help. Take a look at "openssl rand -hex 32" for example.
– mrflash818
2 days ago
add a comment |
@JeffSchaller uh yeah, fold, sorry and "tr" too
– C. Cristi
Nov 19 at 16:59
@KamilMaciorowski it worked but it stopped inserting passwords after the first file, and I don't get why
– C. Cristi
Nov 19 at 17:10
On a Side note:
Next time Give a try to crunch. That would be much easier than writing a script but If you are into learning rather than achieving some task, writing script is Cool :)
– C0deDaedalus
Nov 20 at 4:00
Using openssl to generate the random value may help. Take a look at "openssl rand -hex 32" for example.
– mrflash818
2 days ago
@JeffSchaller uh yeah, fold, sorry and "tr" too
– C. Cristi
Nov 19 at 16:59
@JeffSchaller uh yeah, fold, sorry and "tr" too
– C. Cristi
Nov 19 at 16:59
@KamilMaciorowski it worked but it stopped inserting passwords after the first file, and I don't get why
– C. Cristi
Nov 19 at 17:10
@KamilMaciorowski it worked but it stopped inserting passwords after the first file, and I don't get why
– C. Cristi
Nov 19 at 17:10
On a Side note:
Next time Give a try to crunch. That would be much easier than writing a script but If you are into learning rather than achieving some task, writing script is Cool :)– C0deDaedalus
Nov 20 at 4:00
On a Side note:
Next time Give a try to crunch. That would be much easier than writing a script but If you are into learning rather than achieving some task, writing script is Cool :)– C0deDaedalus
Nov 20 at 4:00
Using openssl to generate the random value may help. Take a look at "openssl rand -hex 32" for example.
– mrflash818
2 days ago
Using openssl to generate the random value may help. Take a look at "openssl rand -hex 32" for example.
– mrflash818
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
I would do it in the following way:
#!/bin/bash
for i in {1..100}
do
cat /dev/urandom | tr -dc '_A-Za-z0-9' | head -c${1:-32} > Password$i
done
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Too many hyphens in the tr character set:tr -dc '_A-Za-z0-9'
and you can replace the letters and numbers with a character class:tr -dc '_[:alnum:]'
– glenn jackman
Nov 19 at 18:58
yours is wrong i think
– C. Cristi
Nov 20 at 16:47
/dev/urandom uses su or sudo, so the script needs to be run as such. Works on my computer running Debian 9. I see it can be condensed. Thanks glenn!
– Michael Prokopec
2 days ago
Fixed my error. Can now be ran as normal user also. Forgot cat and one pipe, memory not as good as I thought. :( @C.Cristi
– Michael Prokopec
2 days ago
I believe that your shell syntax is off a bit. Look at adding some parentheses and replacing the last|
with>
.
– G-Man
2 days ago
|
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I would do it in the following way:
#!/bin/bash
for i in {1..100}
do
cat /dev/urandom | tr -dc '_A-Za-z0-9' | head -c${1:-32} > Password$i
done
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Too many hyphens in the tr character set:tr -dc '_A-Za-z0-9'
and you can replace the letters and numbers with a character class:tr -dc '_[:alnum:]'
– glenn jackman
Nov 19 at 18:58
yours is wrong i think
– C. Cristi
Nov 20 at 16:47
/dev/urandom uses su or sudo, so the script needs to be run as such. Works on my computer running Debian 9. I see it can be condensed. Thanks glenn!
– Michael Prokopec
2 days ago
Fixed my error. Can now be ran as normal user also. Forgot cat and one pipe, memory not as good as I thought. :( @C.Cristi
– Michael Prokopec
2 days ago
I believe that your shell syntax is off a bit. Look at adding some parentheses and replacing the last|
with>
.
– G-Man
2 days ago
|
show 4 more comments
up vote
0
down vote
accepted
I would do it in the following way:
#!/bin/bash
for i in {1..100}
do
cat /dev/urandom | tr -dc '_A-Za-z0-9' | head -c${1:-32} > Password$i
done
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Too many hyphens in the tr character set:tr -dc '_A-Za-z0-9'
and you can replace the letters and numbers with a character class:tr -dc '_[:alnum:]'
– glenn jackman
Nov 19 at 18:58
yours is wrong i think
– C. Cristi
Nov 20 at 16:47
/dev/urandom uses su or sudo, so the script needs to be run as such. Works on my computer running Debian 9. I see it can be condensed. Thanks glenn!
– Michael Prokopec
2 days ago
Fixed my error. Can now be ran as normal user also. Forgot cat and one pipe, memory not as good as I thought. :( @C.Cristi
– Michael Prokopec
2 days ago
I believe that your shell syntax is off a bit. Look at adding some parentheses and replacing the last|
with>
.
– G-Man
2 days ago
|
show 4 more comments
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I would do it in the following way:
#!/bin/bash
for i in {1..100}
do
cat /dev/urandom | tr -dc '_A-Za-z0-9' | head -c${1:-32} > Password$i
done
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I would do it in the following way:
#!/bin/bash
for i in {1..100}
do
cat /dev/urandom | tr -dc '_A-Za-z0-9' | head -c${1:-32} > Password$i
done
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 2 days ago
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered Nov 19 at 18:46


Michael Prokopec
43711
43711
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Michael Prokopec is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
Too many hyphens in the tr character set:tr -dc '_A-Za-z0-9'
and you can replace the letters and numbers with a character class:tr -dc '_[:alnum:]'
– glenn jackman
Nov 19 at 18:58
yours is wrong i think
– C. Cristi
Nov 20 at 16:47
/dev/urandom uses su or sudo, so the script needs to be run as such. Works on my computer running Debian 9. I see it can be condensed. Thanks glenn!
– Michael Prokopec
2 days ago
Fixed my error. Can now be ran as normal user also. Forgot cat and one pipe, memory not as good as I thought. :( @C.Cristi
– Michael Prokopec
2 days ago
I believe that your shell syntax is off a bit. Look at adding some parentheses and replacing the last|
with>
.
– G-Man
2 days ago
|
show 4 more comments
2
Too many hyphens in the tr character set:tr -dc '_A-Za-z0-9'
and you can replace the letters and numbers with a character class:tr -dc '_[:alnum:]'
– glenn jackman
Nov 19 at 18:58
yours is wrong i think
– C. Cristi
Nov 20 at 16:47
/dev/urandom uses su or sudo, so the script needs to be run as such. Works on my computer running Debian 9. I see it can be condensed. Thanks glenn!
– Michael Prokopec
2 days ago
Fixed my error. Can now be ran as normal user also. Forgot cat and one pipe, memory not as good as I thought. :( @C.Cristi
– Michael Prokopec
2 days ago
I believe that your shell syntax is off a bit. Look at adding some parentheses and replacing the last|
with>
.
– G-Man
2 days ago
2
2
Too many hyphens in the tr character set:
tr -dc '_A-Za-z0-9'
and you can replace the letters and numbers with a character class: tr -dc '_[:alnum:]'
– glenn jackman
Nov 19 at 18:58
Too many hyphens in the tr character set:
tr -dc '_A-Za-z0-9'
and you can replace the letters and numbers with a character class: tr -dc '_[:alnum:]'
– glenn jackman
Nov 19 at 18:58
yours is wrong i think
– C. Cristi
Nov 20 at 16:47
yours is wrong i think
– C. Cristi
Nov 20 at 16:47
/dev/urandom uses su or sudo, so the script needs to be run as such. Works on my computer running Debian 9. I see it can be condensed. Thanks glenn!
– Michael Prokopec
2 days ago
/dev/urandom uses su or sudo, so the script needs to be run as such. Works on my computer running Debian 9. I see it can be condensed. Thanks glenn!
– Michael Prokopec
2 days ago
Fixed my error. Can now be ran as normal user also. Forgot cat and one pipe, memory not as good as I thought. :( @C.Cristi
– Michael Prokopec
2 days ago
Fixed my error. Can now be ran as normal user also. Forgot cat and one pipe, memory not as good as I thought. :( @C.Cristi
– Michael Prokopec
2 days ago
I believe that your shell syntax is off a bit. Look at adding some parentheses and replacing the last
|
with >
.– G-Man
2 days ago
I believe that your shell syntax is off a bit. Look at adding some parentheses and replacing the last
|
with >
.– G-Man
2 days ago
|
show 4 more comments
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%2f482803%2ftrying-to-generate-random-password-characters-into-a-file%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
9L Fzjj911ws0 9Urv6qh2L EjE 0icrbV F5iLjlgfMaEFKZKfmpz0YHbjfzEM,kuvoR6UiM9qbNHRx48Qd
@JeffSchaller uh yeah, fold, sorry and "tr" too
– C. Cristi
Nov 19 at 16:59
@KamilMaciorowski it worked but it stopped inserting passwords after the first file, and I don't get why
– C. Cristi
Nov 19 at 17:10
On a Side note:
Next time Give a try to crunch. That would be much easier than writing a script but If you are into learning rather than achieving some task, writing script is Cool :)– C0deDaedalus
Nov 20 at 4:00
Using openssl to generate the random value may help. Take a look at "openssl rand -hex 32" for example.
– mrflash818
2 days ago