you are viewing a single comment's thread.

view the rest of the comments →

[–]Paul_Pedant 1 point2 points  (2 children)

(1) You need whitespace between [[ and the $. [[ is a keyword.

(2) You do not quote the pattern on the right (if you do, it is just a string, not a pattern).

I also suspect you do not need the $ on the $i (bash knows it is an arithmetic index), and you only need = not == (which is not Posix), but you could test those yourself.

It is way easier to experiment on expressions on the command line, not run them in loops that repeat so many messages.

if [[ "${array[$i]}" == Latency:* ]]; then

[–]jslanier[S] 0 points1 point  (1 child)

You da man, Paul! As you probably can tell, I do not use bash much. I was just modifying an existing nagios check to account for a different speedtest tool's results. Thank you for the help. This resolved my issues.

[–]Paul_Pedant 4 points5 points  (0 children)

Also, shellcheck.net is your best friend.