【发布时间】:2016-02-05 06:17:40
【问题描述】:
当我这样做时,
$dig axfr @ns2.3u.net weclapp.com
我得到的输出结果为,
; <<>> DiG 9.8.1-P1 <<>> axfr @ns2.3u.net weclapp.com
; (1 server found)
;; global options: +cmd
weclapp.com. 300 IN SOA ns1.3u.net. ops.3u.net. 2015052602 21600 3600 604800 180
weclapp.com. 300 IN TXT "v=spf1 ip4:185.82.86.236/32 a:smtp.3u.net include:spf.mail.intercom.io include:spf.mailjet.com ?all"
weclapp.com. 300 IN NS ns1.3u.net.
weclapp.com. 300 IN NS ns2.3u.net.
weclapp.com. 300 IN MX 100 smtp.3u.net.
weclapp.com. 300 IN A 185.82.86.245
*.weclapp.com. 300 IN A 185.82.86.245
mailjet._domainkey.weclapp.com. 300 IN TXT "k=rsa\; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDhJ5ZuAL8d8+lkcfbALCNOUxjjM5au1PqFA3VWBCDsSRLaG1t3yYal5RFRcIIoRlVJKf4AaKkvxpsMQJD4EFzEd//UUSIvGIXUfGWs/ywv1TnFY3L0d862mCDcvw88L9p9IdZEkVRAeLBnMqJxAeo2TzAtID+ei4CWUbYxLwfAuwIDAQAB"
weclapp.com. 300 IN SOA ns1.3u.net. ops.3u.net. 2015052602 21600 3600 604800 180
;; Query time: 274 msec
;; SERVER: 83.125.107.34#53(83.125.107.34)
;; WHEN: Fri Feb 5 11:17:36 2016
;; XFR size: 9 records (messages 1, bytes 571)
现在我想在每个输出行中添加一个从文件中读取的数字。我做到了,
#Input.txt
1,weclapp.com,ns2.3u.net
#test.sh
while IFS=, read -r n d s;do
printf "$n,%s\n" $(dig axfr @"$s" "$d")
done < Input.txt
#d is domain , #s is name server ,#n is number from the input file.
当我运行它$sh tesh.sh 时,我得到的输出为。
1,;
1,<<>>
1,DiG
1,9.8.1-P1
1,<<>>
1,axfr
1,@ns2.3u.net
1,weclapp.com
1,;
1,(1
1,server
1,found)
1,;;
1,global
1,options:
1,+cmd
1,weclapp.com.
1,300
1,IN
1,SOA
1,ns1.3u.net.
1,ops.3u.net.
1,2015052602
1,21600
1,3600
1,604800
1,180
1,weclapp.com.
1,300
1,IN
1,TXT
1,"v=spf1
1,ip4:185.82.86.236/32
1,a:smtp.3u.net
1,include:spf.mail.intercom.io
1,include:spf.mailjet.com
1,?all"
1,weclapp.com.
1,300
1,IN
1,NS
1,ns1.3u.net.
1,weclapp.com.
1,300
1,IN
1,NS
1,ns2.3u.net.
1,weclapp.com.
1,300
1,IN
1,MX
1,100
1,smtp.3u.net.
1,weclapp.com.
1,300
1,IN
1,A
1,185.82.86.245
1,*.weclapp.com.
1,300
1,IN
1,A
1,185.82.86.245
1,mailjet._domainkey.weclapp.com.
1,300
1,IN
1,TXT
1,"k=rsa\;
1,p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDhJ5ZuAL8d8+lkcfbALCNOUxjjM5au1PqFA3VWBCDsSRLaG1t3yYal5RFRcIIoRlVJKf4AaKkvxpsMQJD4EFzEd//UUSIvGIXUfGWs/ywv1TnFY3L0d862mCDcvw88L9p9IdZEkVRAeLBnMqJxAeo2TzAtID+ei4CWUbYxLwfAuwIDAQAB"
1,weclapp.com.
1,300
1,IN
1,SOA
1,ns1.3u.net.
1,ops.3u.net.
1,2015052602
1,21600
1,3600
1,604800
1,180
1,;;
1,Query
1,time:
1,167
1,msec
1,;;
1,SERVER:
1,83.125.107.34#53(83.125.107.34)
1,;;
1,WHEN:
1,Fri
1,Feb
1,5
1,11:38:51
1,2016
1,;;
1,XFR
1,size:
1,9
1,records
1,(messages
1,1,
1,bytes
1,571)
应该是这样的,
1,; <<>> DiG 9.8.1-P1 <<>> axfr @ns2.3u.net weclapp.com
1,; (1 server found)
1,;; global options: +cmd
1,weclapp.com. 300 IN SOA ns1.3u.net. ops.3u.net. 2015052602 21600 3600 604800 180
1,......
有人可以建议如何在下面的 dig 命令输出中添加input number (n ) 吗?
【问题讨论】:
-
@anubhava:是的,伙计。但是我不能 grep 特定的字段,如果我得到像上面一样的失真输出。示例:如果我需要输出结果的“A”记录,如何获得?