6

Largest number in array. Help!

view full story
linux-howto

http://www.unix.com – I need to calculate the biggest number in array size n. Example: Users enter: 1 7 4 9 The biggest number is : 9 Simple but I'm really new on this on Shell/Bash! Anything will be helpful! Thanks! Code: #!/bin/bash printf "\tEnter a list of numbers, with spaces: " read -a ARRAY BIG=$1 for i in ${!ARRAY[@]} ; do     if [ $i -gt $BIG ] ; then         BIG=$i     fi done echo "Largest number is $BIG" (HowTos)