Sponsored Content
Full Discussion: Writing a shell Script
Top Forums UNIX for Dummies Questions & Answers Writing a shell Script Post 73747 by Perderabo on Friday 3rd of June 2005 04:32:48 PM
Old 06-03-2005
How about:
Code:
#! /usr/bin/ksh
bc |&
i=0
max=-9999999999999999.0
min=9999999999999999.0
total=0
while print -n "number? " ; read number; do
        ((i=i+1))
        print -p -R "$total + $number"
        read -p total
        print -p -R "$max - $number"
        read -p result
        [[ $result = -* ]] && max=$number
        print -p -R "$number - $min"
        read -p result
        [[ $result = -* ]] && min=$number
done
print -p "$total / $i"
read -p average
echo total = $total
echo average = $average
echo max = $max
echo min = $min
exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with writing shell script

I have the following output. I want to write a script to check for 1. waits > 0 on all rowsand Ratio > .0. if true then send email. ========================= ROLLBACK SEGMENT CONTENTION ========================= If any ratio is > .01 then more rollback segments are needed NAME ... (1 Reply)
Discussion started by: jigarlakhani
1 Replies

2. Shell Programming and Scripting

Need help for writing shell script

Hello ALL, I am fresher in Unix . i need help to write small shell script . Please help me unix guru. I am developing the internal site in my office . the data files are generated in one directory everyday . I have to write shell script to sort those files and put it is internal site . ... (3 Replies)
Discussion started by: deepa20
3 Replies

3. AIX

Difference between writing Unix Shell script and AIX Shell Scripts

Hi, Please give me the detailed Differences between writing Unix Shell script and AIX Shell Scripts. Thanks in advance..... (0 Replies)
Discussion started by: haroonec
0 Replies

4. Shell Programming and Scripting

Writing shell script

Hi, I am a new for shell script. i need to write script using the following commands cd /usres/test # create directory mkdir temp+DATE( i need to append date ) #moving files from one directory to this directory(we need to check total files in source and taget) cd /users/sample ... (2 Replies)
Discussion started by: bmkreddy
2 Replies

5. Shell Programming and Scripting

Need help in writing the shell script

Can anyone please help me in writing a shell script that would check if a particular user(xyz) has logged in, and if yes, the audit daemon needs to be started. When the user logs off the dameon needs to shutdown , and the report needs to be e-mailed to a set of users. (12 Replies)
Discussion started by: ggayathri
12 Replies

6. UNIX and Linux Applications

Need help in writing shell script

I have written a shell script and when i ran the script,for some point of time it is asking to press enter key manually using keyboard.So i need it the enter key in shell itself. ex : in my shell script,i used the command ssh-keygen -t rsa so it asks the enter 3 times. can you please let me know... (3 Replies)
Discussion started by: lkeswar
3 Replies

7. Shell Programming and Scripting

Writing a shell script

Hi I have two files a.log and b.log . i need to append a.log and b.log so that at the end of first line in a.log i need the append the data of first line from b.log and end of the second line in a.log i need to append the data of second line from b.log and so on up to the end of the file can... (3 Replies)
Discussion started by: lalu
3 Replies

8. Shell Programming and Scripting

Need help writing shell script!

Hi, I'm very new to this, so bear with me please. I want to write a sh script (or if there's a better format please let me know) that allows me to, when I run it, print the date to a file (1.out) take 2 arguments (files a.fa and b.fa), run them with another program, outputting to 2.out, and then... (2 Replies)
Discussion started by: ShiGua
2 Replies

9. UNIX for Dummies Questions & Answers

Need help writing shell script!

Hi, I'm very new to this, so bear with me please. I want to write a sh script (or if there's a better format please let me know) that allows me to, when I run it, print the date to a file (1.out) take 2 arguments (files a.fa and b.fa), run them with another program, outputting to 2.out, and then... (4 Replies)
Discussion started by: ShiGua
4 Replies

10. UNIX for Dummies Questions & Answers

Need help in writing shell script

Dear Team, Below is the list of steps i need to perform manually as of now and completely new to shell scripting, could you help in writing a shell script to perform the below procedure? 1. Log in to primary DNS server 2. Check /etc/named.conf if zone is already created (grep –i... (2 Replies)
Discussion started by: VKIRUPHAKARAN
2 Replies
VecStat(3pm)						User Contributed Perl Documentation					      VecStat(3pm)

NAME
Math::VecStat - Some basic numeric stats on vectors SYNOPSIS
use Math::VecStat qw(max min maxabs minabs sum average); $max=max(@vector); $max=max(@vector); ($max,$imax)=max(@vector); ($max,$imax)=max(@vector); $min=min(@vector); $min=min(@vector); ($max,$imin)=min(@vector); ($max,$imin)=min(@vector); $max=maxabs(@vector); $max=maxabs(@vector); ($max,$imax)=maxabs(@vector); ($max,$imax)=maxabs(@vector); $min=minabs(@vector); $min=minabs(@vector); ($max,$imin)=minabs(@vector); ($max,$imin)=minabs(@vector); $sum=sum($v1,$v2,...); $sum=sum(@vector); $sum=sum(@vector); $average=average($v1,$v2,...); $av=average(@vector); $av=average(@vector); $ref=vecprod($scalar,@vector); $ok=ordered(@vector); $ok=ordered(@vector); $ref=sumbyelement(@vector1,@vector2); $ref=diffbyelement(@vector1,@vector2); $ok=allequal(@vector1,@vector2); $ref=convolute(@vector1,@vector2); DESCRIPTION
This package provides some basic statistics on numerical vectors. All the subroutines can take a reference to the vector to be operated on. In some cases a copy of the vector is acceptable, but is not recommended for efficiency. max(@vector), max(@vector) return the maximum value of given values or vector. In an array context returns the value and the index in the array where it occurs. min(@vector), min(@vector) return the minimum value of given values or vector, In an array context returns the value and the index in the array where it occurs. maxabs(@vector), maxabs(@vector) return the maximum value of absolute of the given values or vector. In an array context returns the value and the index in the array where it occurs. minabs(@vector), minabs(@vector) return the minimum value of the absolute of the given values or vector. In an array context returns the value and the index in the array where it occurs. sum($v1,$v2,...), sum(@vector), sum(@vector) return the sum of the given values or vector average($v1,$v2,..), average(@vector), average(@vector) return the average of the given values or vector vecprod($a,$v1,$v2,..), vecprod($a,@vector), vecprod( $a, @vector ) return a vector built by multiplying the scalar $a by each element of the @vector. ordered($v1,$v2,..), ordered(@vector), ordered(@vector) return nonzero iff the vector is nondecreasing with respect to its index. To be used like if( ordered( $lowBound, $value, $highBound ) ){ instead of the (slightly) more clumsy if( ($lowBound <= $value) && ($value <= $highBound) ) { sumbyelement( @array1, @array2 ), diffbyelement(@array1,@array2) return the element-by-element sum or difference of two identically-sized vectors. Given $s = sumbyelement( [10,20,30], [1,2,3] ); $d = diffbyelement( [10,20,30], [1,2,3] ); $s will be "[11,22,33]", $d will be "[9,18,27]". allequal( @array1, @array2 ) returns true if and only if the two arrays are numerically identical. convolute( @array1, @array2 ) return a reference to an array containing the element-by-element product of the two input arrays. I.e., $r = convolute( [1,2,3], [-1,2,1] ); returns a reference to [-1,4,3] median evaluates the median, i.e. an element which separates the population in two halves. It returns a reference to a list whose first element is the median value and the second element is the index of the median element in the original vector. $a = Math::VecStat::median( [9,8,7,6,5,4,3,2,1] ); returns the list reference [ 5, 4 ] i.e. the median value is 5 and it is found at position 4 of the original array. If there are several elements of the array having the median value, e.g. [1,3,3,3,5]. In this case we choose always the first element in the original vector which is a median. In the example, we return [3,1]. =back =head1 HISTORY $Log: VecStat.pm,v $ Revision 1.9 2003/04/20 00:49:00 spinellia@acm.org Perl 5.8 broke test 36, exposing inconsistency in C<median>. Fixed, thanks to david@jamesgang.com. Revision 1.8 2001/01/26 11:10:00 spinellia@acm.org Added function median. Fixed test, thanks to Andreas Marcel Riechert <riechert@pobox.com> Revision 1.7 2000/10/24 15:28:00 spinellia@acm.org Added functions allequal diffbyelement Created a reasonable test suite. Revision 1.6 2000/06/29 16:06:37 spinellia@acm.org Added functions vecprod, convolute, sumbyelement Revision 1.5 1997/02/26 17:20:37 willijar Added line before pod header so pod2man installs man page correctly Revision 1.4 1996/02/20 07:53:10 willijar Added ability to return index in array contex to max and min functions. Added minabs and maxabs functions. Thanks to Mark Borges <mdb@cdc.noaa.gov> for these suggestions. Revision 1.3 1996/01/06 11:03:30 willijar Fixed stupid bug that crept into looping in min and max functions Revision 1.2 1995/12/26 09:56:38 willijar Oops - removed xy data functions. Revision 1.1 1995/12/26 09:39:07 willijar Initial revision BUGS
Let me know. I welcome any appropriate additions for this package. AUTHORS
John A.R. Williams <J.A.R.Williams@aston.ac.uk> Andrea Spinelli <spinellia@acm.org> perl v5.12.4 2011-07-11 VecStat(3pm)
All times are GMT -4. The time now is 01:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy