我想获取一个域名的 IP 地址,dig
然后whois
对该 IP 地址执行查找。
我试过这个:
dig domain.dk +short | whois
一种选择是写:
whois $(dig example.com +short)
请注意,可能会返回多个 IP 地址,dig
因此whois
有时可能会抱怨它不知道要使用哪个 whois 服务器。在这种情况下,您可能需要选择要查找的 IP 地址。你可以选择第一个:
whois $(dig example.com +short | head -n1)
以下是一种更易读的方式,也更接近您的原始问题(@tripleee 在评论中指出):
dig +short example.com | xargs whois
(并dig +short example.com | head -n1 | xargs whois
仅查找由返回的第一个 IP 地址dig
)