作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想从 dhcpd.conf
中删除租约,我在其中给出了要从 Bash 变量中删除的 ip 地址。 dhcpd.conf
示例位于按钮处。
但是我什至不能让它打印我想删除的租约
ip="192.168.234.5"; perl -0777snle 'print if /lease $ip \{.*?\}/' -- -ip=$ip dhcpd.leases
使用 Perl 5.16.3
问题
谁能看出我做错了什么?
lease 192.168.234.5 {
starts 3 2018/11/21 18:53:11;
ends 3 2018/11/21 18:54:11;
tstp 3 2018/11/21 18:54:11;
cltt 3 2018/11/21 18:53:11;
binding state free;
hardware ethernet 14:99:e2:04:52:5c;
uid "\001\024\231\342\004R\\";
}
lease 192.168.234.2 {
starts 3 2018/11/21 20:42:48;
ends 3 2018/11/21 20:52:48;
tstp 3 2018/11/21 20:52:48;
cltt 3 2018/11/21 20:42:48;
binding state free;
hardware ethernet 00:21:5e:90:13:fb;
set MacAddress = "00:21:5E:90:13:FB";
set output = "192.168.234.2,00:21:5E:90:13:FB,(host-decl-name n/a),5E9013FB,(dhcp-client-identifier n/a),(vendor-class-identifier n/a),(agent.remote n/a),(agent.circuit n/a)";
}
lease 192.168.234.13 {
starts 3 2018/11/21 21:38:16;
ends 3 2018/11/21 21:38:27;
tstp 3 2018/11/21 21:38:27;
cltt 3 2018/11/21 21:38:16;
binding state free;
hardware ethernet 00:e0:6f:11:7f:59;
uid "\001\000\340o\021\177Y";
}
最佳答案
基于@Kubator 的 awk answer :
# perl -lnse '$f = 0 if /^lease/; $f = 1 if /^lease $ip [{]/; print if not $f;' \
-- -ip=192.168.234.2 leases
lease 192.168.234.5 {
starts 3 2018/11/21 18:53:11;
ends 3 2018/11/21 18:54:11;
tstp 3 2018/11/21 18:54:11;
cltt 3 2018/11/21 18:53:11;
binding state free;
hardware ethernet 14:99:e2:04:52:5c;
uid "\001\024\231\342\004R\\";
}
lease 192.168.234.13 {
starts 3 2018/11/21 21:38:16;
ends 3 2018/11/21 21:38:27;
tstp 3 2018/11/21 21:38:27;
cltt 3 2018/11/21 21:38:16;
binding state free;
hardware ethernet 00:e0:6f:11:7f:59;
uid "\001\000\340o\021\177Y";
}
关于linux - 如何从 dhcpd.conf 中删除租约?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53444499/
我知道我们可以获取 blob 的租约 60 秒或无限。对于以下代码: var account = CloudStorageAccount.DevelopmentStorageAccount;
我是一名优秀的程序员,十分优秀!