conradin
March 7th, 2012, 02:16 AM
Hi Everyone,
I have a script that gives me host name info based on nslookup, the script works fine, but I need to narrow down what the results are. (brief example below:) Basically, Im looking for strings with the word "maine" in them as is, which I already know is every host in the range. However, I dont necessarily want every host in the range.
What I would like to do is look for hosts with "maine" and "hp*", or "maine" and "cam*" in the hostname, and exclude everything else. But Im not really sure how to do that.
What I dont want to do is re-scan the network, for alternate matching hosts. Though that would work it would also be slow, and probably unnecessary.
Any thoughts, or helpful hints would be much appreciated.
#!/bin/bash
touch local
masq=130.111.218.
for i in `seq 0 255`;
do
nslookup $masq$i | grep maine >> local
done
I have a script that gives me host name info based on nslookup, the script works fine, but I need to narrow down what the results are. (brief example below:) Basically, Im looking for strings with the word "maine" in them as is, which I already know is every host in the range. However, I dont necessarily want every host in the range.
What I would like to do is look for hosts with "maine" and "hp*", or "maine" and "cam*" in the hostname, and exclude everything else. But Im not really sure how to do that.
What I dont want to do is re-scan the network, for alternate matching hosts. Though that would work it would also be slow, and probably unnecessary.
Any thoughts, or helpful hints would be much appreciated.
#!/bin/bash
touch local
masq=130.111.218.
for i in `seq 0 255`;
do
nslookup $masq$i | grep maine >> local
done