As I found out, brace expansion happens before variable expansion; you can accomplish the same objective by replacing for i in {${octet[0]:-0}..255} with for ((i=${octet[0]:-0}; i<=255; i++)) (and do the same for j, k and l) – @markp-fuso