-1

I wrote this question before about bash script

" echo" in bash script empty file

I need script to extract information from whois to excel file (csv)

like:

A         B               C          D                E
domain    ipaddress    ownername   owneraddress   servertype

I wrote small script but ownername and domain address in same column

#!/bin/bash 
while read domain; do
ipaddress=`dig $domain +short` 
domcre=`whois $domain | grep "Created on" | cut -d ":" -f 2 | sed 's/ //' | sed -e :a  -e '$!N;s/ \n/,/;ta'`
domexp=$(whois $domain | grep "Expiration Date" | cut -d ":" -f 2 | sed 's/ //' | sed -e :a -e '$!N;s/ \n/,/;ta') 
ownname=$(whois $domain | grep -A 1 -i "Administrative Contact:" |cut -d ":" -f 2 | sed 's/ //' | sed -e :a -e '$!N;s/ \n/,/;ta')
echo -e  "$domain,$ipaddress,$domcre,$domexp,\t$ownname"  >> data.csv
 done <d.txt
Kara
  • 6,115
  • 16
  • 50
  • 57

2 Answers2

0

Why dont you use awk, awk -F can separate fileds and you can use $1 $2 ...$n to print these fields, i dont have access to a linux box unfortunately at this time otherwise i could send you the exact code but for example you can use following lines to print using awk ls -l | awk -F '{print $1 $2 $9}' > abc.txt

0

You can use this script, you can supply multiple domains to it, you can filter all whois information:

Options:

-r, display registrar information.

-a, display admin information.

-t, display tech information.

-A, display all the information.

https://github.com/ne0anders0n/scripts/blob/master/dos