I want to remove the last entry in my array, and I want the array to show me that it has 1 less entry when I am using the ${#array[@]}. This is the current line
${#array[@]}
The following works fine for Mac/bash@3.x and Linux (ubuntu/bash@4.x)
unset arr[$[${#arr[@]}-1]] # non-sparse array only
in more details:
len=${#arr[@]} idx=$[$len-1] # <=> $(($len-1)) unset arr[$idx]