You can do something like this:
Code:
#!/bin/bash
BOT_RANGE="`echo $1 | cut -d. -f4`"
TOP_RANGE="`echo $2 | cut -d. -f4`"
echo "BOT_RANGE: "${BOT_RANGE}
echo "TOP_RANGE: "${TOP_RANGE}
for (( i=${BOT_RANGE}; i<=${TOP_RANGE}; i++ ))
do
echo "($i) your commands go here"
done
$ ./range.sh 1.2.3.4 1.2.3.8
BOT_RANGE: 4
TOP_RANGE: 8
(4) your commands go here
(5) your commands go here
(6) your commands go here
(7) your commands go here
(8) your commands go here
2 things:
1) I did not use the hyphen in the range. ie 1.2.3.4 1.2.3.8 vs. 1.2.3.4-1.2.3.8
If you cannot get rid og the hyphen, change the following:
Remove these 2 lines:
BOT_RANGE="`echo $1 | cut -d. -f4`"
TOP_RANGE="`echo $2 | cut -d. -f4`"
Replace them with these 4:
LOW_RANGE="`echo $1 | cut -d- -f1`"
HIG_RANGE="`echo $1 | cut -d- -f2`"
BOT_RANGE="`echo ${LOW_RANGE} | cut -d. -f4`"
TOP_RANGE="`echo ${HIG_RANGE} | cut -d. -f4`"
2) This only works if only the last field of the ip ranges are different. But I guess you can take it from here to fix that