i have no understanding of how to write an array or use one, please help!

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:
    make 2 files. one to Input 10 numbers and print out the biggest number, and one to Write a script that can check your permission (read/write/execution) on the input filename as the argument.

  2. Relevant commands, code, scripts, algorithms:
    has to be made using arrays and the declare -a command

  3. The attempts at a solution (include all code and scripts):
    i have no understanding i can do it using arguements but not with an array

  4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    University of michigan, michigan, chang, cse 132

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

  1. declare -a [arrayvariablename] is optional, but good practice
    So:
declare -a myarr
# we now have an empty array called myarr
  1. to assign a value to an array element (one of the members of the array:
myarr[13]=4

This now means that the fourteenth (remember we chose to start counting from 0?)
contains 4.

  1. So we want to enter ten numbers right? We need a loop to count from 0 .. 9
for i in 1 2 3 4 5 6 7 8 9
do
  # put your code here
done

i becomes 0 then 1,2,3..... as the loop goes on.

for i in 0 1 2 3 4 5 6 7 8 9
do
    echo -n 'Enter a number: '
    read myarr[$i]   # read lets you type in a number then assign it to a variable
done

You now have 10 array element, each of which has a number in it. Let's find the biggest one.

echo ${myarr[4]}  # NOTE the ${} part -when you want to get the value in an array element

So let us stomp thru the array and assign something to another variable, call it max

max=-2147483647  # I picked a negative number because your prof will do that to test 
# your code
# poor profs love to to go beyond what they tell you.... they think it somehow teaches (IMO)  

for i in 0 1 2 3 4 5 6 7 8 9
do
   [  $max -lt ${myarr ] && max=${myarr}
done

display the result:

echo "maximum value is $max"

Have fun....

PS:

[ $max -lt ${myarr ] && max=${myarr}

is shell shorthand for if [ ] then do something endif.