0

I need to fill an array and find out what the highest value is, which I've done. With this code:

full=($LASTOCT[*])
for i in $LASTOCT
do
    echo $i
done

echo "Highest value is: $(printf "%d\n" ${full[*]} | sort -n | tail -1) " 

My question is that no matter what number is in the last element of the array, I always get this error: ./ipcheck: line 16: printf: 134[*]: invalid number

Any ideas of what might be causing this? Thanks in advance!

1 Answer 1

1

Change:

full=($LASTOCT[*])

to:

full=(${LASTOCT[*]})
Sign up to request clarification or add additional context in comments.

1 Comment

(facepalm) Lol you know, when you stare at code long enough... Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.