如何批量提取txt文本中带有某个关键字的指定行 并且提取后保存到新的txt文本中
我需要提取以下内容的一些统计数字,我的一个txt中有N个端口的类似数据:Serial2/0.1/2/1/3:0isup,lineprotocolisupHardwarei...
我需要提取以下内容的一些统计数字,我的一个txt中有N个端口的类似数据:
Serial2/0.1/2/1/3:0 is up, line protocol is up
Hardware is Channelized STM-1
MTU 1500 bytes, BW 2048 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation PPP, LCP Open, multilink Open
Link is a member of Multilink bundle Multilink4, crc 16, loopback not set
Keepalive set (10 sec)
Last input 00:00:10, output never, output hang never
Last clearing of "show interface" counters 12w5d
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 6000 bits/sec, 4 packets/sec
2762361 packets input, 144070074 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
6057 input errors, 5967 CRC, 57 frame, 0 overrun, 0 ignored, 33 abort
12122132 packets output, 3145414772 bytes, 0 underruns
0 output errors, 0 collisions, 9 interface resets
0 output buffer failures, 0 output buffers swapped out
2 carrier transitions no alarm present
Serial2/0.1/2/2/1:0 is up, line protocol is up
Hardware is Channelized STM-1
MTU 1500 bytes, BW 2048 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation PPP, LCP Open, multilink Open
Link is a member of Multilink bundle Multilink4, crc 16, loopback not set
Keepalive set (10 sec)
Last input 00:00:04, output never, output hang never
Last clearing of "show interface" counters 12w5d
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 5000 bits/sec, 4 packets/sec
2762361 packets input, 144043890 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
6471 input errors, 6383 CRC, 65 frame, 0 overrun, 0 ignored, 23 abort
12122132 packets output, 3145278227 bytes, 0 underruns
0 output errors, 0 collisions, 9 interface resets
0 output buffer failures, 0 output buffers swapped out
2 carrier transitions no alarm present
我需要提取 Serial 端口号这行
packets input 这行
packets output这行
病分别保存成一个新的txt
如:
Serial2/0.1/2/1/3:0 is up, line protocol is up
Serial2/0.1/2/2/1:0 is up, line protocol is up
这种格式,有高手能帮我想想办法吗?或者有什么工具可以做到吗?高分酬谢~~
qq:85085094 展开
Serial2/0.1/2/1/3:0 is up, line protocol is up
Hardware is Channelized STM-1
MTU 1500 bytes, BW 2048 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation PPP, LCP Open, multilink Open
Link is a member of Multilink bundle Multilink4, crc 16, loopback not set
Keepalive set (10 sec)
Last input 00:00:10, output never, output hang never
Last clearing of "show interface" counters 12w5d
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 6000 bits/sec, 4 packets/sec
2762361 packets input, 144070074 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
6057 input errors, 5967 CRC, 57 frame, 0 overrun, 0 ignored, 33 abort
12122132 packets output, 3145414772 bytes, 0 underruns
0 output errors, 0 collisions, 9 interface resets
0 output buffer failures, 0 output buffers swapped out
2 carrier transitions no alarm present
Serial2/0.1/2/2/1:0 is up, line protocol is up
Hardware is Channelized STM-1
MTU 1500 bytes, BW 2048 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation PPP, LCP Open, multilink Open
Link is a member of Multilink bundle Multilink4, crc 16, loopback not set
Keepalive set (10 sec)
Last input 00:00:04, output never, output hang never
Last clearing of "show interface" counters 12w5d
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)
5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 5000 bits/sec, 4 packets/sec
2762361 packets input, 144043890 bytes, 0 no buffer
Received 0 broadcasts (0 IP multicasts)
0 runts, 0 giants, 0 throttles
6471 input errors, 6383 CRC, 65 frame, 0 overrun, 0 ignored, 23 abort
12122132 packets output, 3145278227 bytes, 0 underruns
0 output errors, 0 collisions, 9 interface resets
0 output buffer failures, 0 output buffers swapped out
2 carrier transitions no alarm present
我需要提取 Serial 端口号这行
packets input 这行
packets output这行
病分别保存成一个新的txt
如:
Serial2/0.1/2/1/3:0 is up, line protocol is up
Serial2/0.1/2/2/1:0 is up, line protocol is up
这种格式,有高手能帮我想想办法吗?或者有什么工具可以做到吗?高分酬谢~~
qq:85085094 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询