I came across a script with some code like this:
arr=($p)
np=${#arr[*]}
p is a string of integer pairs: “0,1 2,4 3,5” etc. First of all, I’m not 100% sure what the () do in the first line, but I think it just turns the things into an associative array of sorts? That may not be correct either …. But more than that, I’m at a complete loss as to what the second line does.
The parentheses in the first turn the result into an array, and it will be assigned indexes starting from 0 and split according to
IFS(which by default includes whitespace). The${#arr[*]}}gives the number of elements in the array.