用于解析区域文件的 UNIX 脚本(这是最好的代码吗?)
发现以下内容: http://mike.murraynet.net/2009/08/23/parsing-the-verisign-zone-file-with-os-x/
unix-masters 可以看一下它,看看它是否是在区域文件中收集唯一域名的最佳方法?
对于 .NET 域: grep “^[a-zA-Z0-9-]+ NS .” net.zone|sed “s/NS .//”|uniq >>> netdomains.txt
对于 .COM 域: grep “^[a-zA-Z0-9-]+ NS .” com.zone|sed “s/NS .//”|uniq >>> comdomains.txt
对于 .EDU 域: grep “^[a-zA-Z0-9-]+ NS .” edu.zone|sed “s/NS .//”|uniq >>> edudomains.txt
FOund the following on: http://mike.murraynet.net/2009/08/23/parsing-the-verisign-zone-file-with-os-x/
Can unix-masters have a look at it and see if its the best possible way to gather the unique domainsnames in a zone file?
For .NET domains:
grep “^[a-zA-Z0-9-]+ NS .” net.zone|sed “s/NS .//”|uniq >> netdomains.txt
For .COM domains:
grep “^[a-zA-Z0-9-]+ NS .” com.zone|sed “s/NS .//”|uniq >> comdomains.txt
For .EDU domains:
grep “^[a-zA-Z0-9-]+ NS .” edu.zone|sed “s/NS .//”|uniq >> edudomains.txt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就我个人而言,我会在进一步处理之前使用
named-checkzone
规范化区域文件的格式:无可否认,命令行更长,但它避免了对潜在脆弱的正则表达式匹配的需要。
named-checkconf
输出保证在第四个字段中包含资源记录类型 (NS
),并在第一个字段中包含整个域名。FWIW,
named-checkzone
还会对区域文件输出进行排序,从而确保uniq
正常工作。Personally, I'd use
named-checkzone
to canonicalise the format of the zone file before further processing:The command line is admittedly longer, but it avoids the need for a potentially fragile regular expression match. The
named-checkconf
output is guaranteed to have the resource record type (NS
) in the fourth field, and the whole domain name in the first field.FWIW,
named-checkzone
also sorts the zone file output, which ensures thatuniq
works properly.这是一个较旧的例子。我和我的对比了一下,格式还是一样的。
http://www.adspeed.org/2006/ 04/parsing-verisign-comnet-zone-files.html
这是一个 new.zone 文件示例。我添加了底部的一个,这样您就可以看到当名称服务器也是 .net 时情况如何,它省略了它。
Here is an older example. I compared with mine and the format is still the same.
http://www.adspeed.org/2006/04/parsing-verisign-comnet-zone-files.html
this is a new.zone file example. I added the bottom one so you can see how it is when nameserver is also .net, it leaves it out.