AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 545070
Accepted
Scheintod
Scheintod
Asked: 2013-10-11 00:56:48 +0800 CST2013-10-11 00:56:48 +0800 CST 2013-10-11 00:56:48 +0800 CST

linux:更短的“主机”命令输出

  • 772

我正在使用 dns 来管理我的虚拟主机。为此,我使用 host 命令查询我的名称服务器以获取我需要的某些值。例如:

> host -t txt mycl1.vz
mycl1.vz.myserver.de descriptive text "1026"

但我只需要1026作为没有喋喋不休的答案。目前我正在使用 sed 将其删除,例如:

| sed -e 's/.*descriptive text "\(.*\)"/\1/'

但这似乎有点“不稳定”,我想知道是否没有一些命令可以首先给我简单的输出?

linux
  • 2 2 个回答
  • 1692 Views

2 个回答

  • Voted
  1. Best Answer
    dawud
    2013-10-11T01:03:13+08:002013-10-11T01:03:13+08:00

    dig(1)与+short标志一起使用:

    $ host -t txt google.com
    google.com descriptive text "v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all"
    
    $ dig -t txt google.com +short
    "v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all"
    

    如果要删除引号,只需通过以下方式过滤输出sed:

    $ dig -t txt google.com +short | sed 's/"//g'
    v=spf1 include:_spf.google.com ip4:216.73.93.70/31 ip4:216.73.93.72/31 ~all
    
    • 8
  2. Bgs
    2013-10-11T01:54:50+08:002013-10-11T01:54:50+08:00

    正如 dawud 指出的那样,我的第一选择是挖掘。如果您坚持使用“主机”,则可以将 sed 替换为:

    cut -d \" -f 2
    
    • 1

相关问题

  • Linux 主机到主机迁移

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 在 RHEL4 上修改 CUPS 中的现有打印机设置

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve