11-03-2015
Generating a Random String of 'n' length
Hi,
How can I generate a string of random characters (alpha+numeric) of a particular length ?
For e.g. for
n=5, output = 'kasjf'
n=10, output = 'hedbcd902k'
Also, please let me know if random (valid) dates could also be generated.
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello, need a way to generate numbers within 0.5-1.5 range
Has to be totally random:
0.6
1.1
0.8
1.5
0.6
and so on....
How to? (10 Replies)
Discussion started by: TehOne
10 Replies
2. Shell Programming and Scripting
Hi,
I am having trouble with generating random numbers. can this be done with awk?
So I have a file that looks like this:
23 30
24 40
26 34
So column1 is start and column2 is end. I want to generate 3 random #'s between start and stop:
So the output will look like this:
... (9 Replies)
Discussion started by: phil_heath
9 Replies
3. Programming
Hi,
How can we generate 16 digit random nos in C. (10 Replies)
Discussion started by: ajaysahoo
10 Replies
4. Programming
Im new to C, and Im having a hard time getting a random number.
In bash, I would do something similar to the following to get a random number;
#!/bin/bash
seed1=$RANDOM
seed2=$RANDOM
seed3=$RANDOM
SEED=`expr $seed1 * $seed2 / $seed3`
echo ${SEED%.*}
Now, in online examples... (4 Replies)
Discussion started by: trey85stang
4 Replies
5. Shell Programming and Scripting
I want to generate an awk function that generated a Gaussian distributed set of random numbers. I need to implement the thing below in awk. Rnd is just a uniform random number between 0 and 1
function rgaussian(r1, r2) {
Do
v1 = 2 * Rnd - 1
v2 = 2 * Rnd - 1
... (0 Replies)
Discussion started by: kristinu
0 Replies
6. Shell Programming and Scripting
Hi,
I hope someone can share there scripting fu on my problem,
I would like to delete the 3rd character from a random length of string starting from the end
Example
Output
Hope you can help me..
Thanks in advance.. (3 Replies)
Discussion started by: jao_madn
3 Replies
7. UNIX for Dummies Questions & Answers
Hello.
Could anyone help me with my little annoying problem?
I have to generate a 512 MB file made up with random data using DD. After some internet digging I found out that the command is:
dd if=/dev/urandom of=/exemple/file bs=512MB
After running this command the... (2 Replies)
Discussion started by: razolo13
2 Replies
8. Shell Programming and Scripting
Hi there I am trying to generate a random number between 40 and 70 using the shell here is my code so far and it keeps going above 70. all help much appreciated!
comp=$(( RANDOM%70+40 ))
echo $comp (4 Replies)
Discussion started by: faintingquiche
4 Replies
9. Shell Programming and Scripting
Having a hard time with this. Very new to scripting and linux. Spent all sunday trying to do this. Appreciate some help and maybe help breaking down what the syntax does.
Create a Bash program. It should have the following properties
• Creates a secret number between 1 and 100
i. The... (3 Replies)
Discussion started by: LINUXnoob15
3 Replies
10. Shell Programming and Scripting
Hi Guys and gals...
As you know I am getting to grips with POSIX and hit this stumbling block.
Generating two random numbers 0 to 255 POSIXly. Speed in not important hence the 'sleep 1' command.
I have done a demo that works, but it sure is ugly! Is there a better way?
#!/bin/sh
# Random... (12 Replies)
Discussion started by: wisecracker
12 Replies
LEARN ABOUT DEBIAN
string::mkpasswd
String::MkPasswd(3pm) User Contributed Perl Documentation String::MkPasswd(3pm)
NAME
String::MkPasswd - random password generator
SYNOPSIS
use String::MkPasswd qw(mkpasswd);
print mkpasswd();
# for the masochisticly paranoid...
print mkpasswd(
-length => 27,
-minnum => 5,
-minlower => 1, # minlower is increased if necessary
-minupper => 5,
-minspecial => 5,
-distribute => 1,
);
ABSTRACT
This Perl library defines a single function, "mkpasswd()", to generate random passwords. The function is meant to be a simple way for
developers and system administrators to easily generate a relatively secure password.
DESCRIPTION
The exportable "mkpasswd()" function returns a single scalar: a random password. By default, this password is nine characters long with a
random distribution of four lower-case characters, two upper-case characters, two digits, and one non-alphanumeric character. These
parameters can be tuned by the user, as described in the "ARGUMENTS" section.
ARGUMENTS
The "mkpasswd()" function takes an optional hash of arguments.
-length
The total length of the password. The default is 9.
-minnum
The minimum number of digits that will appear in the final password. The default is 2.
-minlower
The minimum number of lower-case characters that will appear in the final password. The default is 2.
-minupper
The minimum number of upper-case characters that will appear in the final password. The default is 2.
-minspecial
The minimum number of non-alphanumeric characters that will appear in the final password. The default is 1.
-distribute
If set to a true value, password characters will be distributed between the left- and right-hand sides of the keyboard. This makes it
more difficult for an onlooker to see the password as it is typed. The default is false.
-fatal
If set to a true value, "mkpasswd()" will Carp::croak() rather than return "undef" on error. The default is false.
If -minnum, -minlower, -minupper, and -minspecial do not add up to -length, -minlower will be increased to compensate. However, if
-minnum, -minlower, -minupper, and -minspecial add up to more than -length, then "mkpasswd()" will return "undef". See the section
entitled "EXCEPTION HANDLING" for how to change this behavior.
EXCEPTION HANDLING
By default, "mkpasswd()" will return "undef" if it cannot generate a password. Some people are inclined to exception handling, so
String::MkPasswd does its best to accommodate them. If the variable $String::MkPasswd::FATAL is set to a true value, "mkpasswd()" will
Carp::croak() with an error instead of returning "undef".
EXPORT
None by default. The "mkpasswd()" method is exportable.
SEE ALSO
<http://expect.nist.gov/#examples>, mkpasswd(1)
AKNOWLEDGEMENTS
Don Libes of the National Institute of Standards and Technology, who wrote the Expect example, mkpasswd(1).
AUTHOR
Chris Grau <cgrau@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2003-2010 by Chris Grau
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or,
at your option, any later version of Perl 5 you may have available.
perl v5.10.1 2010-10-18 String::MkPasswd(3pm)