Sponsored Content
Full Discussion: Random Variable
Top Forums Shell Programming and Scripting Random Variable Post 302840149 by wisecracker on Sunday 4th of August 2013 03:58:57 PM
Old 08-04-2013
Line 1 of YOUR code sets an integer random number R variable to 0 OR 1 dependant on the program run(time).
Line 2 does the same between 0 to 9 but in this code is wasted time as it effectively is not used and therefore does nothing...

The conditional statement looks for 0 as the crucial value from the variable R and sets the TEXT variable to "F".

ANY other value would give the TEXT variable as "X"...

Code:
#!/bin/bash

R=$(($RANDOM % 2))
echo "$R"
delay=$(($RANDOM % 10))
echo "$delay"
        if [ $R -gt 0 ]
        then
                TEXT='X'
                echo "$TEXT"
        else
                TEXT='F'
                echo "$TEXT"
        fi

I hope that is lucid enough...
This User Gave Thanks to wisecracker For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

random ip address

suppose that my network client process does not possess an effective root UID. is it possible to change the client host machine ip address to a random number? (3 Replies)
Discussion started by: xtrix
3 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. Shell Programming and Scripting

replacing a number with random variable inside shell script

Hi All. I need help for the below logic. I ve a file like following input file: NopTX(5) // should be remain same as input ----Nop(@100); //1 Nop(90); //2 --Nop(80); //3 @Nop(70); //4 --@Nop(60); //5 @Nop@(@50); //6 --Nop@( 40); ... (3 Replies)
Discussion started by: user_prady
3 Replies

4. Shell Programming and Scripting

$random

I need to use the $RANDOM command to get a line from a list of lines in a file randomly. file is help go three house film how do i randomly get one word without looking into the file? (6 Replies)
Discussion started by: relle
6 Replies

5. 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

6. Programming

random number

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

7. 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

8. 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

9. 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

10. UNIX for Beginners Questions & Answers

Random letters

Hi there, first of all this is not homework...this is a new type of exercise for practicing vocabulary with my students. I have a file consisting of two columns, separated by a tab, each line consisting of a word and its definition, separated by a line break. What i need is to replace a... (15 Replies)
Discussion started by: eldeingles
15 Replies
DROP TEXT SEARCH 
CONFIGURATION(7) SQL Commands DROP TEXT SEARCH CONFIGURATION(7) NAME
DROP TEXT SEARCH CONFIGURATION - remove a text search configuration SYNOPSIS
DROP TEXT SEARCH CONFIGURATION [ IF EXISTS ] name [ CASCADE | RESTRICT ] DESCRIPTION
DROP TEXT SEARCH CONFIGURATION drops an existing text search configuration. To execute this command you must be the owner of the configura- tion. PARAMETERS
IF EXISTS Do not throw an error if the text search configuration does not exist. A notice is issued in this case. name The name (optionally schema-qualified) of an existing text search configuration. CASCADE Automatically drop objects that depend on the text search configuration. RESTRICT Refuse to drop the text search configuration if any objects depend on it. This is the default. EXAMPLES
Remove the text search configuration my_english: DROP TEXT SEARCH CONFIGURATION my_english; This command will not succeed if there are any existing indexes that reference the configuration in to_tsvector calls. Add CASCADE to drop such indexes along with the text search configuration. COMPATIBILITY
There is no DROP TEXT SEARCH CONFIGURATION statement in the SQL standard. SEE ALSO
ALTER TEXT SEARCH CONFIGURATION [alter_text_search_configuration(7)], CREATE TEXT SEARCH CONFIGURATION [create_text_search_configura- tion(7)] SQL - Language Statements 2010-05-14 DROP TEXT SEARCH CONFIGURATION(7)
All times are GMT -4. The time now is 05:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy