andrelucio.fc@yahoo.com [shell-script]
2017-07-25 20:21:31 UTC
Opa, pessoal.
Eu preciso os dados das linhas com o conteúdo "lease" e "hardware ethernet", achei a seguinte solução que deu certo: sed -n '/lease/{h;g;p};/hardware/{h;g;p};'dhcp.log. Vocês conhecem alguma outra solução além dessa para pegar os dados de linha especificas?
Dados:
# The format of this file is documented in the dhcpd.leases(5) manual page.
lease 10.0.0.46 {
starts 1 2017/07/17 18:20:50;
ends 1 2017/07/17 19:04:07;
tstp 1 2017/07/17 19:04:07;
cltt 1 2017/07/17 18:20:50;
binding state free;
hardware ethernet b3:bb:1f:22:2a:61;
}
lease 10.0.0.50 {
starts 1 2017/07/17 18:30:08;
ends 1 2017/07/17 20:30:08;
tstp 1 2017/07/17 20:30:08;
cltt 1 2017/07/17 18:30:08;
binding state free;
hardware ethernet 2a:cc:cc:d1:ab:cf;
}
lease 10.0.0.48 {
starts 5 2017/07/21 14:12:20;
ends 5 2017/07/21 16:12:20;
tstp 5 2017/07/21 16:12:20;
cltt 5 2017/07/21 14:12:20;
binding state free;
hardware ethernet 1d:aa:fd:31:0b:0a;
}
lease 10.0.0.40 {
starts 5 2017/07/14 13:44:36;
ends 5 2017/07/21 13:44:36;
tstp 5 2017/07/21 13:44:36;
cltt 5 2017/07/14 13:44:36;
binding state free;
hardware ethernet 11:30:xd:b3:xx:da;
Eu preciso os dados das linhas com o conteúdo "lease" e "hardware ethernet", achei a seguinte solução que deu certo: sed -n '/lease/{h;g;p};/hardware/{h;g;p};'dhcp.log. Vocês conhecem alguma outra solução além dessa para pegar os dados de linha especificas?
Dados:
# The format of this file is documented in the dhcpd.leases(5) manual page.
lease 10.0.0.46 {
starts 1 2017/07/17 18:20:50;
ends 1 2017/07/17 19:04:07;
tstp 1 2017/07/17 19:04:07;
cltt 1 2017/07/17 18:20:50;
binding state free;
hardware ethernet b3:bb:1f:22:2a:61;
}
lease 10.0.0.50 {
starts 1 2017/07/17 18:30:08;
ends 1 2017/07/17 20:30:08;
tstp 1 2017/07/17 20:30:08;
cltt 1 2017/07/17 18:30:08;
binding state free;
hardware ethernet 2a:cc:cc:d1:ab:cf;
}
lease 10.0.0.48 {
starts 5 2017/07/21 14:12:20;
ends 5 2017/07/21 16:12:20;
tstp 5 2017/07/21 16:12:20;
cltt 5 2017/07/21 14:12:20;
binding state free;
hardware ethernet 1d:aa:fd:31:0b:0a;
}
lease 10.0.0.40 {
starts 5 2017/07/14 13:44:36;
ends 5 2017/07/21 13:44:36;
tstp 5 2017/07/21 13:44:36;
cltt 5 2017/07/14 13:44:36;
binding state free;
hardware ethernet 11:30:xd:b3:xx:da;