吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 308|回复: 11
收起左侧

[经验求助] 批量提取txt文本中特定关键字所在行内容

[复制链接]
hhn 发表于 2024-4-20 16:36
50吾爱币
一个文件内有多个文本,示例文本格式如下:想要提取所有文本内红色字符(所有红色字符的前后字符格式都一样)。输出到一个新的可修改名称的txt

sysname NMHH-MC-CMNET-BRAS01-ME60-X16
#
/$[System Integration Version]
/$SystemIntegrationVersion = 3.0

[Rack_1]
[SubRack_1]

[BackPlane]
/$[ArchivesInfo Version]
/$ArchivesInfoVersion=3.0


[Board Properties]
BoardType=ME0Z1BKP16A
BarCode=2102352024N0GA000005
Item=02352024
Description=MultiserviceEngine60,ME0Z1BKP16A,ME60-X16 Integrated Chassis Components(Including 8 DC Power)
Manufactured=2016-10-09
VendorName=Huawei
IssueNumber=00
CLEICode=
BOM=


[Slot_1]
/$[Board Integration Version]
/$BoardIntegrationVersion=3.0


[Main_Board_0]
/$[ArchivesInfo Version]
/$ArchivesInfoVersion=3.0


[Board Properties]
BoardType=ME03LPUF50CA0
BarCode=210305462910GA000156
Item=03054629
Description=ME60,ME03LPUF50CA0,Flexible Card Broadband Service Unit(BSUF-51,2 sub-slots)
Manufactured=2016-10-16
VendorName=Huawei
IssueNumber=00
CLEICode=
BOM=

最佳答案

查看完整内容

【笔记】TXT关键字搜索程序 https://www.52pojie.cn/thread-470976-1-1.html

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

freelive 发表于 2024-4-20 16:36
【笔记】TXT关键字搜索程序
https://www.52pojie.cn/thread-470976-1-1.html

dogface 发表于 2024-4-20 19:57
linux下:grep -E "sysname|BarCode=" filename.txt|sed "s/sysname //g"|sed "s/BarCode=//g" >newfilename.txt
windows需要安装cmder,这里下载:
https://share.weiyun.com/iz05Q7wM
sgywzx 发表于 2024-4-20 23:58
 楼主| hhn 发表于 2024-4-23 18:42
dogface 发表于 2024-4-20 19:57
linux下:grep -E "sysname|BarCode=" filename.txt|sed "s/sysname //g"|sed "s/BarCode=//g" >newfilename ...

这咋用的  在windows模拟linux环境? 这还得现学了
dogface 发表于 2024-4-23 18:54
工具和命令都发出来了,您安装后发命令就行了
小邑走天下 发表于 2024-4-23 19:34
本帖最后由 小邑走天下 于 2024-4-23 19:35 编辑

工具:https://yiqingchen.lanzoue.com/iJjLR1w90jqd
选择要筛选的文件,关键字用逗号隔开
 楼主| hhn 发表于 2024-4-24 17:23
小邑走天下 发表于 2024-4-23 19:34
工具:https://yiqingchen.lanzoue.com/iJjLR1w90jqd
选择要筛选的文件,关键字用逗号隔开

文件或目录损坏且无法读取
小邑走天下 发表于 2024-4-24 18:28
hhn 发表于 2024-4-24 17:23
文件或目录损坏且无法读取

把txt文件另存为一下,选择utf-8编码,文件里边有乱码的内容嘛?
 楼主| hhn 发表于 2024-4-25 09:38
小邑走天下 发表于 2024-4-24 18:28
把txt文件另存为一下,选择utf-8编码,文件里边有乱码的内容嘛?

是筛选工具打开提示的损坏  换目录也不行
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-6 04:33

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表