Trying to write a script to parse a list of domains to confirm their registrars are being updated correctly. I run the whois against a domain name and all I want are the lines that START with "Name Server" or "Domain Name"
When I run and grep the 'whois' output from the shell, it works perfectly:
$ whois customerdomain.com | egrep -e ^'Name Server|^Domain Name'
Domain Name: CUSTOMERDOMAIN.COM
Name Server: ns.buydomains.com
Name Server: this-domain-for-sale.com
But when I take a list of domains and put them in a shell script, the "or" operator is ignored and the "Domain name" fails to be included in the output:
Example script (whois-list.sh):
#!/bin/bash
whois customerdomain.com | egrep -e ^'Name Server|^Domain Name'
whois contoso.com | egrep -e ^'Name Server|^Domain Name'
whois google.com | egrep -e ^'Name Server|^Domain Name'
whois microsoft.com | egrep -e ^'Name Server|^Domain Name'
Output:
$ ./whois-list.sh
Name Server: ns.buydomains.com
Name Server: this-domain-for-sale.com
Name Server: ns1-205.azure-dns.com
Name Server: ns3-205.azure-dns.org
Name Server: ns2-205.azure-dns.net
Name Server: ns4-205.azure-dns.info
I've tried like 10 different variations that all seem to work fine at the prompt, but always seem to dump the 'or' operator when run from the script.