ipplusone.txt

#!/bin/sh

MaxValue=255    # highest valid IP octet value
Count=1 #Matt hacking away the loop

ip="$(ifconfig | grep -A 1 'eth0' | tail -1 | cut -d ':' -f 2 | cut -d ' ' -f 1)"

baseaddr="$(echo $ip | cut -d. -f1-3)"
lsv="$(echo $ip | cut -d. -f4)"

while [ $count -gt 0 ]
do
   if [ $lsv -eq $MaxValue ] ; then
    # here you'll need to increment the third level IP value,
    # but that might cascade into the second, or the first.
    # consider the case of 17.255.255.255 + 1
    echo "edge case needs to be written"
  fi
  echo $baseaddr.$lsv
  lsv=$(( $lsv + 1 ))
  count=$(( $count - 1 ))
done

exit 0

ċ
changeEtcHosts.txt
(1k)
Harry Robinson,
Aug 30, 2016, 3:14 PM
Comments