linux random password generator - repeat n times

2

dd if=/dev/urandom count=200 bs=1 2>/dev/null|tr "\n" " "|sed 's/[^a-zA-Z0-9]//g'|cut -c-16

How do I repeat it set number of times?

Phil

Posted 2010-08-17T18:32:09.007

Reputation: 23

Answers

2

Try this:

for i in `seq 10` ; do <your command here> ; done

it will repeat <your command here> 10 times.

cYrus

Posted 2010-08-17T18:32:09.007

Reputation: 18 102

Works xD (15 characters) – Phil – 2010-08-17T19:03:46.977

1@Phil: With Bash, it's not necessary to use seq. You can do for i in {1..10} or for ((i=1;i<=10;i++)) and it saves forking another external executable. – Paused until further notice. – 2010-08-17T19:08:37.543

@Dennis: Sure, you've right, but this job doesn't seem a time-critical task. – cYrus – 2010-08-17T19:15:54.970

2

If the point is to learn shell programming, see cYrus's answer.

If the point is to generate a password, many distributions ship with pwgen.

Gilles 'SO- stop being evil'

Posted 2010-08-17T18:32:09.007

Reputation: 58 319