Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Script producing error, Program to calculate maximum number Post 302345169 by scripter.online on Tuesday 18th of August 2009 03:11:19 PM
Old 08-18-2009
1.you have not mentioned $symbol for max
2. No space between if and [

Code:
 
max=0
echo Enter 10 numbers , one at a time
for i in 1 2 3 4 5 6 7 8 9 10
do
read n
max=`expr $max + $n`
if[ $n -gt $max ]

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to make a script run for a maximum of "x" number of hours only

How to make a script run for a maximum of "x" number of hours only (7 Replies)
Discussion started by: ScriptDummy
7 Replies

2. Shell Programming and Scripting

How to calculate the maximum value & min value

I have a file as like below, 10:20:30.45 START 10.20.30.40 10:20:31.46 HELLO 10.20.30.40 10:20:32.46 START 10.20.30.41 10:20:33.44 END 10.20.30.40 10:20:35.44 HELLO 10.20.30.41 10:20:36.56 HELLO 10.20.30.41 10:20:37.78 HELLO 10.20.30.41 10:20:38.99 START 10.20.30.40... (1 Reply)
Discussion started by: gobinath
1 Replies

3. UNIX for Dummies Questions & Answers

maximum number of arguments

Hi, What is the maximum number of arguments that could be passed to zsh ? To find out that I tried a simple script. And the maximum number of arguments that could be passed turned out to be 23394 #! /bin/zsh arg=1 i=1 subIndex=23000 while do arg=$arg" "$i i=$(($i + 1))... (9 Replies)
Discussion started by: matrixmadhan
9 Replies

4. UNIX for Dummies Questions & Answers

ls - maximum number of files

what is the maximum number ls can list down (6 Replies)
Discussion started by: karnan
6 Replies

5. Shell Programming and Scripting

get positive number n as argument script must calculate the factorial of its argument

Can someone please help me with this SHELL script? I need to create a script that gets a positive number n as an argument. The script must calculate the factorial of its argument. In other words, it must calculate n!=1x2x3x...xn. Note that 0!=1. Here is a start but I have no clue how to... (3 Replies)
Discussion started by: I-1
3 Replies

6. AIX

aix 4.2 : using dd of=/dev/rmt0 producing error

I want to compress backup files to tape using compress on our AIX 4.2 - Our TAR does not have compression. - I do not want to use local storage to compress as most of the filesystems are pretty full. - the only compressing tool we have is 'compress' - tapes are 5Gb 8mm I am trying this... (10 Replies)
Discussion started by: Browser_ice
10 Replies

7. Shell Programming and Scripting

Script not working...producing 0's and not number

Below is my script: #!/bin/sh #echo "Please type oracle-lower case please:" #read X #if ] #then # echo "Sorry that is not oracle, try again" # exit 1 #else # echo Thank you #fi find / -name oracle 2>/dev/null | while read line do bdf 2>/dev/null |... (6 Replies)
Discussion started by: bigben1220
6 Replies

8. Shell Programming and Scripting

What is the maximum number of parameter we can pass to a shell script function?

what is the maximum number of parameter we can pass to a shell script function (8 Replies)
Discussion started by: alokjyotibal
8 Replies

9. Shell Programming and Scripting

Calculate the number of days between 2 dates - bash script

I wrote the day calculator also in bash. I would like to now, that is it good so? #!/bin/bash datum1=`date -d "1991/1/1" "+%s"` datum2=`date "+%s"` diff=$(($datum2-$datum1)) days=$(($diff/(60*60*24))) echo $days Thanks in advance for your help! (3 Replies)
Discussion started by: kovacsakos
3 Replies

10. Shell Programming and Scripting

awk script not producing output

Hi, I have a text file with some thousands of rows of the following kind (this will be referred to as the inputFileWithColorsAndNumbers.txt): Blue 6 Red 4 Blue 3 Yellow 4 Red 7 Colors in the left column and a number in the right one for each line. I want to run an awk... (5 Replies)
Discussion started by: Zooma
5 Replies
MT_RAND(3)								 1								MT_RAND(3)

mt_rand - Generate a better random value

SYNOPSIS
int mt_rand (void ) DESCRIPTION
int mt_rand (int $min, int $max) Many random number generators of older libcs have dubious or unknown characteristics and are slow. By default, PHP uses the libc random number generator with the rand(3) function. The mt_rand(3) function is a drop-in replacement for this. It uses a random number generator with known characteristics using the Mersenne Twister, which will produce random numbers four times faster than what the average libc rand() provides. If called without the optional $min, $max arguments mt_rand(3) returns a pseudo-random value between 0 and mt_getrandmax(3). If you want a random number between 5 and 15 (inclusive), for example, use mt_rand(5, 15). Caution This function does not generate cryptographically secure values, and should not be used for cryptographic purposes. If you need a cryptographically secure value, consider using random_int(3), random_bytes(3), or openssl_random_pseudo_bytes(3) instead. PARAMETERS
o $min - Optional lowest value to be returned (default: 0) o $max - Optional highest value to be returned (default: mt_getrandmax(3)) RETURN VALUES
A random integer value between $min (or 0) and $max (or mt_getrandmax(3), inclusive), or FALSE if $max is less than $min. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.4 | | | | | | | Issues an E_WARNING and returns FALSE if $max < | | | $min. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 mt_rand(3) example <?php echo mt_rand() . " "; echo mt_rand() . " "; echo mt_rand(5, 15); ?> The above example will output something similar to: 1604716014 1478613278 6 NOTES
Caution The distribution of mt_rand(3) return values is biased towards even numbers on 64-bit builds of PHP when $max is beyond 2^32. This is because if $max is greater than the value returned by mt_getrandmax(3), the output of the random number generator must be scaled up. SEE ALSO
mt_srand(3), mt_getrandmax(3), random_int(3), random_bytes(3), openssl_random_pseudo_bytes(3), rand(3). PHP Documentation Group MT_RAND(3)
All times are GMT -4. The time now is 03:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy