I have made whois
script in bash:
#!/bin/bash
# Store the list of domains in an array
while read domain
do
# Output the header
echo "Domain,Registrar,Creation Date,Expiration Date"
# Perform a WHOIS lookup for each domain
whois_output=$(whois "$domain")
# Extract the relevant information from the WHOIS output
registrar=$(echo "$whois_output" | grep "Registrar:" | awk '{print $2}')
creation_date=$(echo "$whois_output" | grep "Creation Date:" | awk '{print $3}')
expiration_date=$(echo "$whois_output" | grep "Expiration Date:" | awk '{print $3}')
# Output the information in a row
echo "$domain,$registrar,$creation_date,$expiration_date" >> domain_info.csv
done < domains.csv
The output is coming in vertical way:
Facebook.com
Creation date
Update date
And I want data in horizontal way like:
Facebook.com,creation date , update date
For the vertical to horizontal conversion, I think the simplest fix is to simply remove the newlines which can be done by piping to tr
command:
# Output the information in a row
echo "$domain,$registrar,$creation_date,$expiration_date" | tr -d '\n' >> domain_info.csv