如何批量提取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
展开
 我来答
yes___no
2011-09-21 · TA获得超过3153个赞
知道大有可为答主
回答量:1988
采纳率:100%
帮助的人:2055万
展开全部
假设待处理文件是myfile.txt, 只要在DOS提示符下运行:
findstr "Serial" myfile.txt > Serial.txt
findstr "packets input" myfile.txt > packets_input.txt
findstr "packets output" myfile.txt > packet_output.txt
或者把以上三行保存为f.bat点击运行即可.
veket_linux
2011-09-21 · TA获得超过4092个赞
知道大有可为答主
回答量:3809
采纳率:0%
帮助的人:4482万
展开全部
我来用 autoit 做个工具给你吧
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式