Greetings. I'm completely new to shell scripting and quickly trying to catch on. Here's my scenario:
I have a text file, named ip.txt, containing IP addresses. I want to automatically perform a whois query on each address in the file, search the output for the country, and then put both the IP address and the corresponding country together into a new file.
Here's what I've come up with so far:
Quote:
for i in `cat ./ip.txt`; do whois $i | grep -i 'country:'>>./country.txt; done
The problem with this, obviously, is that it doesn't list the IP address in the output file.
To the best that I can tell, I somehow need to store the grep results as a variable, and then maybe echo both variables into a new file.
Am I on the right track?
In the event that it matters, the system I'm trying to do this on is Debian 6.0.3.
Thanks!