I am looking for a way to expand this iterator before execution at the moment it sets $i to {0..255} and it should set $i to 0 to start with and iterate. Tried this can you see an example? What about delayed expansion is there something that can expand first before the do command?
for i in {${octet[0]:-0}..255}; do
for j in {${octet[1]:-0}..255}; do
for k in {${octet[2]:-0}..255}; do
for l in {${octet[3]:-0}..255}; do
echo "ntpdate -q $i.$j.$k.$l"
output=$(ntpdate -q $i.$j.$k.$l 2>&1)
if [[ $? = 0 ]]; then
echo "ntpdate -q $i.$j.$k.$l" >> bashntpdate.log
echo "$output" >> bashntpdate.log
echo "" >> bashntpdate.log
echo "$output"
fi
done
done
done
done
At the moment this outputs:
ntpdate -q {10..255}.{20..255}.{10..255}.{100..255}