如何限制 whois 命令的输出?

如何限制 whois 命令的输出?

如何从 PTR whois 查询中仅获取所有者/组织名称?我不需要所有其他条目,只需要有关所有权的部分(在本例中为 google)。

Edit /usr/bin/whois 74.125.236.52 或任何 IP get OrgName

  #
  # Query terms are ambiguous.  The query is assumed to be:
  #     "n 74.125.236.52"
  #
  # Use "?" to get help.
  #

  #
  # The following results may also be obtained via:
  # http://whois.arin.net/rest/nets;q=74.125.236.52?showDetails=true&showARIN=false&ext=netref2
  #

  NetRange:       74.125.0.0 - 74.125.255.255
  CIDR:           74.125.0.0/16
  OriginAS:
  NetName:        GOOGLE
  NetHandle:      NET-74-125-0-0-1
  Parent:         NET-74-0-0-0-0
  NetType:        Direct Allocation
  RegDate:        2007-03-13
  Updated:        2012-02-24
  Ref:            http://whois.arin.net/rest/net/NET-74-125-0-0-1


  OrgName:        Google Inc.
  OrgId:          GOGL
  Address:        1600 Amphitheatre Parkway
  City:           Mountain View
  StateProv:      CA
  PostalCode:     94043
  Country:        US
  RegDate:        2000-03-30
  Updated:        2011-09-24
  Ref:            http://whois.arin.net/rest/org/GOGL

  OrgAbuseHandle: ZG39-ARIN
  OrgAbuseName:   Google Inc
  OrgAbusePhone:  +1-650-253-0000
  OrgAbuseEmail:  [email protected]
  OrgAbuseRef:    http://whois.arin.net/rest/poc/ZG39-ARIN

  OrgTechHandle: ZG39-ARIN
  OrgTechName:   Google Inc
  OrgTechPhone:  +1-650-253-0000
  OrgTechEmail:  [email protected]
  OrgTechRef:    http://whois.arin.net/rest/poc/ZG39-ARIN

  #
  # ARIN WHOIS data and services are subject to the Terms of Use
  # available at: https://www.arin.net/whois_tou.html
  #

答案1

如果你想要域名IP 地址所有者(而不是,比如说公司名称dig -x),也许使用?会更好。

$ dig +short -x 74.125.236.52
maa03s04-in-f20.1e100.net.

- 编辑 -

如果你只想要输出中的“OrgName:”行whois,你可以用以下命令将其单独列出grep

$ whois 74.125.236.52 | grep OrgName
OrgName:        Google Inc.

但正如其他地方提到的,这可能并不总是有效,因为输出格式没有在任何地方指定。

答案2

输出whois不是标准化的,因此没有任何切换来仅获取您正在寻找的信息。

您需要的是一些解析(grep/ sed/awk等等),而本网站不适合。请在 Stack Overflow 上提问。

答案3

man whois 返回如何格式化数据以获取您喜欢的数据

例子

whois -H -K 37.247.93.241

% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf

% Note: this output has been filtered.
% Only primary keys and abuse contacts will be visible.
% No other contact information will be shown.

% Abuse contact for '37.247.93.0 - 37.247.93.255' is '[email protected]'

inetnum:        37.247.93.0 - 37.247.93.255

route:          37.247.64.0/19
origin:         AS21413

% This query was served by the RIPE Database Query Service version 1.97.2 (HEREFORD)

相关内容