Sponsored Content
Full Discussion: $random
Top Forums Shell Programming and Scripting $random Post 302213729 by g.pi on Thursday 10th of July 2008 08:15:19 PM
Old 07-10-2008
$RANDOM is a built-in bash function that returns a random integer in the range 0 - 32767.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting a random file

Hello, I am very new to shell scripting. This problem seems quite easy so it should be quite easy (I hope ^^) I want to get a random file from a directory. this file will be in one subdirectory, and it will contain spaces. code I have got so far: N=find ./*/*.jpg | wc -l ((N=RANDOM%N)) ... (6 Replies)
Discussion started by: davidY
6 Replies

2. Shell Programming and Scripting

Random

My problem is as follow and i hope you can help: I currently have this function: stored_word() { number=$RANDOM let "number %= 21" case $number in 0 ) echo "energy" ;; 1 ) echo "touch" ;; 2 ) echo "climbing" ;; 3 ) echo "declare" ;; 4 ) echo "marry" ;; 5 ) echo "relax" ... (8 Replies)
Discussion started by: keyvan
8 Replies

3. UNIX for Dummies Questions & Answers

random words

Hi there folks, for an exercise for my pupils (you know i am always thinking of them!) i need to randomly re-arrange the words (blank space separated) in a sentence (a line in a textfile). Any inspiration?? Txk so much. (9 Replies)
Discussion started by: eldeingles
9 Replies

4. Ubuntu

expect script for random password and random commands

Hi I am new to expect. Please if any one can help on my issue its really appreciable. here is my issue: I want expect script for random passwords and random commands generation. please can anyone help me? Many Thanks in advance (0 Replies)
Discussion started by: vanid
0 Replies

5. Programming

random number

How can I choose randomly the row numbers of my file in awk? (4 Replies)
Discussion started by: Homa
4 Replies

6. UNIX for Dummies Questions & Answers

Random Crashing

Over the last month or so my CentOS server has been crashing for reasons I do not know. It has been running for over a year with regular yum updates without problems. The load on the server is perfectly normal with CPU usage at 5-6% and RAM usage at less than half of 32GB of RAM (multiple smaller... (3 Replies)
Discussion started by: spinner0205
3 Replies

7. Shell Programming and Scripting

Random ordering

1 2 4 5 3 I would like to use a script so that i can randomly rearrange these numbers such as 3 5 2 4 1 Thanks! (3 Replies)
Discussion started by: johnkim0806
3 Replies

8. Shell Programming and Scripting

Random Variable

Hi, Could you please let me know what the following code does, I know that it means generating random numbers, however not sure what is the entire purpose. R=$(($RANDOM % 2)) delay=$(($RANDOM % 10)) if then TEXT='X' else ... (3 Replies)
Discussion started by: susankoperna1
3 Replies

9. Shell Programming and Scripting

Need to generate a file with random data. /dev/[u]random doesn't exist.

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)
Discussion started by: Devyn
7 Replies

10. Homework & Coursework Questions

Random numbers

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! Write a shell script that will take the sum of two random number? Ex: Random n1 +Random n2 = result i tries to write it but i had some dufficulties ... (3 Replies)
Discussion started by: renegade755
3 Replies
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
All times are GMT -4. The time now is 05:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy