I am working on a BASH shell script where I need to be able to check and see if the IP address returned from:
dig $HOSTNAME +short
is within a particular subnet or not. For example, if part of 192.168.10.x or 10.130.10.x then do z else do y.
I am not sure how to manipulate or check the IP address after I have it stored in a variable so that I can build out the logical test described above.
I ended up using the following code to make it work:
Thanks for everyone’s help and explaining things to me to allow me to further learn about scripting. It is really appreciated!