我正在使用DNS来pipe理我的虚拟主机。 为了做到这一点,我查询我的名称服务器与主机命令为特定的值是需要的。 例如:
> host -t txt mycl1.vz mycl1.vz.myserver.de descriptive text "1026"
但我只需要1026作为答案没有喋喋不休。 目前我使用sed来删除它,如:
| sed -e 's/.*descriptive text "\(.*\)"/\1/'
但是这似乎有点“不稳定”,我想知道是不是有一些命令可以让我原来的输出呢?
使用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
dawud指出,我的第一select是挖掘。 如果你坚持“主机”,你可以用sedreplace:
cut -d \" -f 2