0
如何使用sed提取包含MAC地址的每个lease {...}
部分的IP address
和MAC address
?sed脚本 - 如何从配置节中提取IP和MAC地址?
示例输入:
lease 192.168.0.188 {
starts 0 2015/10/18 10:02:20;
ends 0 2015/10/18 10:32:20;
cltt 0 2015/10/18 10:02:20;
binding state active;
next binding state free;
hardware ethernet 2c:44:fd:25:f7:fc;
uid "\001,D\375%\367\374";
client-hostname "708-PC";
}
lease 192.168.0.71 {
starts 0 2015/10/18 10:02:16;
ends 0 2015/10/18 10:02:16;
tstp 0 2015/10/18 10:02:16;
cltt 0 2015/10/18 10:02:16;
binding state abandoned;
next binding state free;
}
输出示例:
192.168.0.188
2c:44:fd:25:f7:fc
我尝试使用:
s/lease // ;s/hardware ethernet // ;s/^ // ;/^[^0-9]/d ;s/[^0-9a-z\:\.][\{]// ;s/\;// ;/^$/d
这确实然而,不正确的工作。