0

我想获取一个域名的 IP 地址,dig然后whois对该 IP 地址执行查找。

我试过这个:

dig domain.dk +short | whois
4

1 回答 1

1

一种选择是写:

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

于 2014-10-30T12:49:35.433 回答