title: clear memory with variable
body: <p>Currently I'm creating a little script in BASH that will ask the user to fill in a new IP-address, subnet and gateway. That input goes to a file which will be writen to /etc/network/interface..</p>
  
  <p>I got the script working, but it isn't bullet proof.</p>
  
  <p>When the user input, is not a number but an alphabetic character, It returns and the user needs to fill again a number.
  When the user still uses a alphabetic character, the script continues, even though giving a error.</p>
  
  <p>My code:</p>
  
  <pre><code>    echo "Fill in your IP"
      read NEW_IP
  
      oldIFS=$IFS
      IFS=.
      set -- $NEW_IP
  
      while [ $# -ne "4" ]; do  
        echo "Must have 4 parts"
          read NEW_IP
          set -- $NEW_IP 
      done
  
      for oct in $1 $2 $3 $4; do
        echo $oct | egrep "^[0-9]+$" &gt;/dev/null 2&gt;&amp;1 
        while [ "$?" -ne "0" ]; do
            echo "$oct is not numeric. fill your IP in the correct format;"
          read NEW_IP
        set -- $NEW_IP 
      done
  </code></pre>
  
  <p>I'm new with bash, above I didn't make it by my self. I've found this script on the internet. The while and do, I made that by my self as a loop.
  Everytime the user fills in a wrong number It must return untill the user filled in a correct format.</p>
  
  <p>The real problem lies at the second half of the code. When I fill in a wrong IP like 10.10.10.a, I get the error like I want and I have to fill in for the second time my IP.
  When I type 10.41.12.r, an error occured but this time, not complaining about the r at the end, but still complaining about the a which I inserted at the first. 10.41.12 will be checkt, but that last character is different.</p>
  
  <p>I can imagine that everything will be stored in memory, but how do I clear that?
  unset or $oct=<br>
  won't work</p>
  
  <p>Hope that someone can help me with this. It's my first time programming, and this is giving me a headache</p>
  
  <p>thanks.</p>
  
  <p>Dave</p>