[TriLUG] bash scripting - formatting and verifying input

Roy Vestal rvestal at trilug.org
Thu Feb 28 10:09:44 EST 2008


Folks,
 I'm writing a script that asks for the ip of a machine. I need to be 
able to read the info and verify it's in the correct format or ask again:

------<snip>-------

   echo ""
   echo ""
   echo "Please enter the IP Address"

   read IPADDR


--------<end snip>------

I know it's simple, but this is going to be a somewhat automated system 
that needs to verify the ip address. I was thinking sed but it seems a 
little complicated. I just need to verify it's in the xxx.xxx.xxx.xxx 
format, not any specific numbers in the octets.

Any suggestions?
TIA



More information about the TriLUG mailing list