[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] bat脚本怎么提取 a,b文本行 格式 以 逗号, 分割 a=b 的文本行?

bat提取 a,b文本行 格式  以 逗号, 分割 a=b 的文本行???怎么写?

例如:文本1.txt

https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url]
https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/accessibility/[/url]
https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/history/[/url]
https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/map/[/url]
https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/sheweishou...htm[/url]
https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/xiaos...htm[/url]
https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/contra...shtml[/url]
https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/wa/[/url]
https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/?fromdefa...[/url]
https://www.baidu.com/s?wd=site:[url]www.sxxinju.com/[/url],https://www.baidu.com/s?wd=site:[url]www.sxxinju.com/[/url]
https://www.baidu.com/s?wd=site:[url]www.sxxinju.com/[/url],https://www.baidu.com/s?wd=site:[url]www.sxxinju.com/sheweishou...htm[/url]

提取 以 逗号, 分割 a=b 的文本行    生成文本2.txt

https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url],https://www.baidu.com/s?wd=site:[url]www.qq.com/[/url]
https://www.baidu.com/s?wd=site:[url]www.sxxinju.com/[/url],https://www.baidu.com/s?wd=site:[url]www.sxxinju.com/[/url]

回复 1# idc878787


如果文本行数较多,可以试试命令行工具 gawk.exe 效率如何:
http://bcn.bathome.net/s/tool/index.html?key=gawk
  1. gawk "BEGIN{FS=OFS=\",\"}{if($1==$2)print}" 1.txt > 2.txt
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

回复 2# qixiaobin0715


       3Q  3Q

TOP

  1. @echo off
  2. (for /f "tokens=1* delims=," %%i in (1.txt) do if "%%i"=="%%j" echo,%%i,%%j)>2.txt
复制代码

TOP

返回列表