1

I have a list of IP addresses within a comma delimited CSV file. They are all located within column A. (ip.csv)

I would like to use WHOIS, or if there is a better way please advise to check each of these IP addresses and then output the details to a new csv file (resolved.csv).

This will need a column per descriptor in the WHOIS record, such as inetnum, netname, descr, country...

Ultimately I am looking to parse the results to some form of useful data.

Having installed WHOIS the

 `whois 86.63.229.33`

works great but this is complicated for new user. Merci

Sandy
  • 11
  • 2
  • From the top of my head: `while IFS=, read -r ip _; do whois "$ip"; done < your_csv_file | awk '/inetnum|country|netname|descr/{print}'` – Valentin Bajrami Jul 27 '19 at 18:10

1 Answers1

0

I've written a little snippet that matches a few lines generated by whois. Adjust it to your needs

#!/usr/bin/env bash

shopt -s extglob  # needed to use  @(inetnum|country....)
while read -r line
 do 
   if [[ $line == @(inetnum|country|desc)* ]]; then
    echo "$line"
   fi
 done < <(awk -F, '{system("whois " $1)}' your_csv_file )
Valentin Bajrami
  • 9,244
  • 3
  • 25
  • 38
  • Thank you. I possibly did not explain myself so well. What you have provided is great but I was hoping to append the results of IP Address located in Column A to the following columns. For instance Column A will always have the IP Address, Column B 'inetnum', Column C 'Country' Column D 'descr' etc - Thank you again. Sandy – Sandy Jul 28 '19 at 09:43