Sponsored Content
Top Forums Shell Programming and Scripting Largest number in array. Help! Post 302610785 by agama on Wednesday 21st of March 2012 08:34:56 PM
Old 03-21-2012
You'll need to populate your array like this:

Code:
typeset -a ARRAY
printf "\tEnter a list of numbers, with spaces: "
read  ans
ARRAY=( $ans )

There are other ways, but I think this is easiest.

You need to set big to something real, not $1. Safe to set to first value of the array.
Code:
BIG=${ARRAY[0]}

You want to look at aray elements, not the indexes:

Code:
for i in ${ARRAY[@]}

This User Gave Thanks to agama For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

search the largest number and duplicates string

Hi, My input file contain list of username, and it may have name with number as a suffix (if duplicated). Ex: mary john2 mike john3 john5 mary10 alexa So i want to check with a specific username (without suffix number) how many duplicated name, and what is the... (13 Replies)
Discussion started by: fongthai
13 Replies

2. Shell Programming and Scripting

checking the smallest and largest number

Hi All, My script is reading a log file line by line log file is like ; 19:40:22 :INFO Total time taken to Service External Request---115ms 19:40:25 DEBUG : Batch processed libdaemon.x86_64 0-0.10-5.el5 - u 19:40:22 INFO Total time taken to Service External Request---20ms 19:40:24... (4 Replies)
Discussion started by: subin_bala
4 Replies

3. UNIX for Dummies Questions & Answers

How to print largest and smallest number.

Hey. This is pretty easy stuff but I'm learning the basics of Unix at the moment so keep that in mind. I have to: 1) Write a C-shell script to monitor user activity on the server for 13 minutes. 2) Then print the smallest and largest number of users during these 13 minutes. I have this: 1)... (2 Replies)
Discussion started by: amp10388
2 Replies

4. Shell Programming and Scripting

perl + array and incrementing number

morning guys and gals, I am haveing a problem, a friend helped me out with this script but i dont know how to add incrementing number for each movie in movie.list. this is what i have so far. any assistance would be great. I have removed the GT and LT symbols so you can see what is going on... (5 Replies)
Discussion started by: Optimus_P
5 Replies

5. Shell Programming and Scripting

How to insert the number to an array

Hi I work in ksh88 and have a file which has several "set -A " statements: set -A PNUM_LSTM 2713 4124 2635 270 2529 2259 2214 set -A PNUM_LSTM $* for pn in ${PNUM_LSTM} etc... I need to add another number, lets say 555, to the first line ONLY so only the the first line will be updated... (2 Replies)
Discussion started by: aoussenko
2 Replies

6. Shell Programming and Scripting

How to initialize array with a larger number?

Language: ksh OS: SunOS I have been getting the 'subscript out of range' error when the below array variable gets elements greater that 1024. I understand that 1024 is the default size for 'set -A' dynamic array, but is there a way to initialize it with a larger number? set -A arr `grep... (6 Replies)
Discussion started by: ChicagoBlues
6 Replies

7. Shell Programming and Scripting

awk second largest, third largest value

I have two text files like this: file1.txt: 133 10 133 22 133 13 133 56 133 78 133 98 file2.txt: 158 38 158 67 158 94 158 17 158 23 I'm basically trying to have awk check the second largest value of the second column of each text file, and cat it to its own text file. There... (13 Replies)
Discussion started by: theawknewbie
13 Replies

8. Shell Programming and Scripting

Taking largest (negative) number from column of coordinates and adding positive form to every other

Hello all, I'm new to the forums and hope to be able to contribute something useful in the future; however I must admit that what has prompted me to join is the fact that currently I need help with something that has me at the end of my tether. I have a PDB (Protein Data Bank) file which I... (13 Replies)
Discussion started by: crunchgargoyle
13 Replies

9. Shell Programming and Scripting

Locating the largest number and performing division

I have a tab delimited file with the following format 1 r 109 45 3 5 6 7 2 f 300 249 5 8 10 3 g 120 4 5 110 0 4 t 400 300 250 0 0 ..... ..... 100,000 lines I would like to get the largest number in columns 4, 5, 6, 7, 8 and divide that largest number with the number in column 3.... (4 Replies)
Discussion started by: Kanja
4 Replies

10. Shell Programming and Scripting

Reduce the number of lines by using Array

I have the following code to count the number of how many times the name occurred in one file. The code is working fine and the output is exactly what I want. The problem is the real code has more than 50 names in function listname which cause function name to have more than 50 case ,and function... (14 Replies)
Discussion started by: samsan
14 Replies
MDADM.CONF(5)							File Formats Manual						     MDADM.CONF(5)

NAME
mdadm.conf - configuration for management of Software Raid with mdadm SYNOPSIS
/etc/mdadm.conf DESCRIPTION
mdadm is a tool for creating, managing, and monitoring RAID devices using the md driver in Linux. Some common tasks, such as assembling all arrays, can be simplified by describing the devices and arrays in this configuration file. SYNTAX The file should be seen as a collection of words separated by white space (space, tab, or newline). Any word that beings with a hash sign (#) starts a comment and that word together with the remainder of the line is ignored. Any line that starts with white space (space or tab) is treated as though it were a continuation of the previous line. Empty lines are ignored, but otherwise each (non continuation) line must start with a keyword as listed below. The keywords are case insensitive and can be abbreviated to 3 characters. The keywords are: DEVICE A device line lists the devices (whole devices or partitions) that might contain a component of an MD array. When looking for the components of an array, mdadm will scan these devices (or any devices listed on the command line). The device line may contain a number of different devices (separated by spaces) and each device name can contain wild cards as defined by glob(7). Also, there may be several device lines present in the file. For example: DEVICE /dev/hda* /dev/hdc* DEV /dev/sd* DEVICE /dev/discs/disc*/disc ARRAY The ARRAY lines identify actual arrays. The second word on the line should be the name of the device where the array is normally assembled, such as /dev/md1. Subsequent words identify the array, or identify the array as a member of a group. If multiple identi- ties are given, then a component device must match ALL identities to be considered a match. Each identity word has a tag, and equals sign, and some value. The tags are: uuid= The value should be a 128 bit uuid in hexadecimal, with punctuation interspersed if desired. This must match the uuid stored in the superblock. super-minor= The value is an integer which indicates the minor number that was stored in the superblock when the array was created. When an array is created as /dev/mdX, then the minor number X is stored. devices= The value is a comma separated list of device names. Precisely these devices will be used to assemble the array. Note that the devices listed there must also be listed on a DEVICE line. level= The value is a raid level. This is not normally used to identify an array, but is supported so that the output of mdadm --examine --scan can be use directly in the configuration file. num-devices= The value is the number of devices in a complete active array. As with level= this is mainly for compatibility with the output of mdadm --examine --scan. spare-group= The value is a textual name for a group of arrays. All arrays with the same spare-group name are considered to be part of the same group. The significance of a group of arrays is that mdadm will, when monitoring the arrays, move a spare drive from one array in a group to another array in that group if the first array had a failed or missing drive but no spare. MAILADDR The mailaddr line gives an E-mail address that alerts should be sent to when is running in --monitor mode (and was given the --scan option). There should only be one MAILADDR line and it should have only one address. PROGRAM The program line gives the name of a program to be run when mdadm --monitor detects potentially interesting events on any of the arrays that it is monitoring. This program gets run with two or three arguments, they being the Event, the md device, and possibly the related component device. There should only be one program line and it should be give only one program. EXAMPLE
DEVICE /dev/sd[bcdjkl]1 DEVICE /dev/hda1 /dev/hdb1 # /dev/md0 is known by it's UID. ARRAY /dev/md0 UUID=3aaa0122:29827cfa:5331ad66:ca767371 # /dev/md1 contains all devices with a minor number of # 1 in the superblock. ARRAY /dev/md1 superminor=1 # /dev/md2 is made from precisey these two devices ARRAY /dev/md2 devices=/dev/hda1,/dev/hda2 # /dev/md4 and /dev/md5 are a spare-group and spares # can be moved between them ARRAY /dev/md4 uuid=b23f3c6d:aec43a9f:fd65db85:369432df spare-group=group1 ARRAY /dev/md5 uuid=19464854:03f71b1b:e0df2edd:246cc977 spare-group=group1 MAILADDR root@mydomain.tld PROGRAM /usr/sbin/handle-mdadm-events SEE ALSO
mdadm(8), md(4). MDADM.CONF(5)
All times are GMT -4. The time now is 06:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy