我的/ etc / hosts看起来像这样:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.13.11 idm.myhost.com
192.168.13.10 dnsf.myhost.com
192.168.13.11 idm.myhost.com
192.168.13.10 dnsf.myhost.com
192.168.13.11 idm.myhost.com
192.168.13.10 dnsf.myhost.com
192.168.13.10 temp1.myhost.com
我可以通过以下查询查询重复的行:
print /files/etc/hosts/*/canonical["idm.myhost.com"]
或使用正则表达式
defvar mypath /files/etc/hosts
print $mypath/*/*[.=~ regexp("dnsf.myhost.com")]
但是我不能用简单的rm删除这些匹配的行
rm /files/etc/hosts/*/canonical["idm.myhost.com"]
问题是,augtool只是从节点中删除规范叶,而ipaddr仍然保留。它导致保存功能返回错误。我不想使用bash脚本,而是尝试使用augeas本身解决问题。协助,请...
PS我找不到此有用工具的完整教程或文档。我要感谢有人可以提出一份好的文件。我搜索了所有网络,并找到了一些简单的示例。
您的表达式选择规范节点而不是主机节点。如果要删除主机节点,则需要使用:
rm /files/etc/hosts/*[canonical="idm.myhost.com"]
这将选择任何条目下/files/etc/hosts
,其 canonical
子节点具有价值idm.myhost.com
。
至于文件,有一个教程的Augeas网站上,以及对一些文档的Augeas维基。
YouTube上还有Augeas的视频介绍。
我大约7年前开始写一本书,现在仍然可以在网上找到它,但从来没有花时间完成它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句