- 论坛徽章:
- 0
|
有一个文件hosts.cfg内容类似如下格式:
define host {
host_name host1
alias server1
address 192.168.0.1
contact_groups admin
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check-host-alive
}
define host {
host_name host2
alias server2
address 192.168.0.2
contact_groups admin
notification_interval 10
notification_period 24x7
notification_options d,u,r
check_command check-host-alive
}
......
想要输入结果如下格式:
host1 192.168.0.1 w,u,c,r
host2 192.168.0.2 d,u,r
......
也就是分别取出host_name,address和notification_options的值放在一行里(用空格分隔),请问用sed or awk等工具如何实现,谢谢! |
|