Here's a little puzzler. Seeing as "seq" only works in decimals, it's a
little tricky.
Basically, if someone gives me a pair of IP's, like
10.55.2.9
and
10.10.29.2
I want something like a "for $ip in $ips" type loop. I'm thinking at the
moment, something like:
IP_start=10.10.2.9
IP_end=10.10.6.0
for i in `seq 1 4`
do
eval "IP_start_$i=`echo $IP_start | cut -f$i -d. `"
eval "IP_end_$i=`echo $IP_end | cut -f$i -d. `"
done
counter1=$IP_start_1
while [ $counter1 -le $IP_end_1 ] ; do
counter2=$IP_start_2
while [ $counter2 -le $IP_end_2 ] ; do
counter3=$IP_start_3
while [ $counter3 -le $IP_end_3 ] ; do
counter4=$IP_start_4
while [ $counter4 -le $IP_end_4 ] ; do
echo "$counter1.$counter2.$counter3.$counter4"
counter4=$((counter4+1))
done
counter3=$((counter3+1))
done
counter2=$((counter2+1))
done
counter4=$((counter4+1))
done
But, how do I do the "base 256" thing ?
--
When I say 'free', I mean 'free': free from bond, of chain or command:
to go where you will, even to Mordor, Saruman, if you desire. "
-- Gandalf, paraphrasing the choice between Free and Non-free software
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!