How to generate a random integer with specific range(for example, from 1 to 1000)?
Also, how to convert a floating point number into a integer? (2 Replies)
I want to be able to generate a random number within a korn shell script..
Preferably i would like to be able to state how many digits should be in this random number... ie 4 digits or 5 digits etc
Any ideas? (2 Replies)
Hello All...
Can someone help me generate a random password which will be 7 characters long which contains alpha-numeric characters using shell script.
I am looking to store the output of the script that generates the password to a variable within a script and use it as the password.
... (5 Replies)
I need a function to generate a random alphanumeric password in C code. It needs to be between 6-8 characters and follow the following rules:
Reject if same char appears # time: 4 or more
Reject if same char appears consecutively: 3 or more
I have the following random password working for... (2 Replies)
I saw this formula to generate random number between two specified values in shell script.the following.
$(((RANDOM%(max-min+divisibleBy))/divisibleBy*divisibleBy+min))
Give a example in book.
Generate random number between 6 and 30.like this.
$(((RANDOM%30/3+1)*3))
But I have a... (1 Reply)
Hi All,
I have extracted some report from database for few activities done.
Now I have a requirement to add some random time(In range of 10-35) in front of each activity.
Can be generated random numbers in any bash/sh shell within a given number range, let's say in between 10-30.
... (10 Replies)
Dear all,
I have a question. I have a txt file say 4000 rows X 1800 Column. I 'd like to creat a new column as the first column which is a column of random numbers (n=4000)
thanks a lot!
Lin (2 Replies)
Need to use dd to generate a large file from a sample file of random data. This is because I don't have /dev/urandom.
I create a named pipe then:
dd if=mynamed.fifo do=myfile.fifo bs=1024 count=1024
but when I cat a file to the fifo that's 1024 random bytes:
cat randomfile.txt >... (7 Replies)
Hi all...
Apologies for any typos, etc...
This took a while but it didn't beat me...
Although there are many methods of generating random numbers in a POSIX shell this uses integer maths and a simple C source to create an executable to get epoch to microseconds accuracy if it is needed. I take... (8 Replies)
Discussion started by: wisecracker
8 Replies
LEARN ABOUT FREEBSD
random
RANDOM(6) BSD Games Manual RANDOM(6)NAME
random -- random lines from a file or random numbers
SYNOPSIS
random [-elrUuw] [-f filename] [denominator]
DESCRIPTION
Random has two distinct modes of operations. The default is to read in lines from the standard input and randomly write them out to the
standard output with a probability of 1 / denominator. The default denominator for this mode of operation is 2, giving each line a 50/50
chance of being displayed.
The second mode of operation is to read in a file from filename and randomize the contents of the file and send it back out to standard out-
put. The contents can be randomized based off of newlines or based off of space characters as determined by isspace(3). The default
denominator for this mode of operation is 1, which gives each line a chance to be displayed, but in a random(3) order.
The options are as follows:
-e If the -e option is specified, random does not read or write anything, and simply exits with a random exit value of 0 to denominator
- 1, inclusive.
-f filename
The -f option is used to specify the filename to read from. Standard input is used if filename is set to '-'.
-l Randomize the input via newlines (the default).
-r The -r option guarantees that the output is unbuffered.
-U Tells random(6) that it is okay for it to reuse any given line or word when creating a randomized output.
-u Tells random(6) not to select the same line or word from a file more than once (the default). This does not guarantee uniqueness if
there are two of the same tokens from the input, but it does prevent selecting the same token more than once.
-w Randomize words separated by isspace(3) instead of newlines.
SEE ALSO random(3), fortune(6)HISTORY
The functionality to randomizing lines and words was added in 2003 by Sean Chittenden <seanc@FreeBSD.org>.
BUGS
No index is used when printing out tokens from the list which makes it rather slow for large files (10MB+). For smaller files, however, it
should still be quite fast and efficient.
BSD February 8, 2003 BSD