标题: [文本处理] [已解决]如何提取findstr命令的返回结果并赋值给变量 [打印本页]
作者: lijinan 时间: 2015-11-27 09:46 标题: [已解决]如何提取findstr命令的返回结果并赋值给变量
本帖最后由 lijinan 于 2015-11-27 10:55 编辑
文本文件,使用findstr "20.*-v5i64.exe" "md5-hash.txt">test.txt后,获得test.txt是如下结果:
81ED49CF905E359316CBC91DCF730450 20151123-004-v5i64.exe
4DB055083ABD0EA0FD088A9C4FA21FAD 20151123-023-v5i64.exe
A699005803070610E54A5017D3795534 20151123-038-v5i64.exe
7F6A9E31BA1C2CD3F3533857FF9287C4 20151124-003-v5i64.exe
D3C6FB6E7F5E3715E95FBD6D1C5C8E1D 20151124-021-v5i64.exe
30C46E1A68E85A580F325A389F04D3B2 20151124-050-v5i64.exe
988B398187554E58DE08EA20E021E21C 20151125-002-v5i64.exe
473598308C748E9EC54F9D3A588C4314 20151125-020-v5i64.exe
00474AA3A048E4C18F170F46C81A6CCF 20151125-038-v5i64.exe
1BEF34F697DC8901EEE3A08B3A122D03 20151126-001-v5i64.exe
4DED3CC3E02038D15AA2EC8320E57B52 20151126-018-v5i64.exe
使用for /f "delims=" %%a in (test.txt) do set e=%%a
echo %e:~33%得到最后一行中“20151120-067-v5i64.exe”
有没有方法把上述两个命令合成一条,即不需要test.txt.
请大侠支招,多谢!
作者: flyinnet9 时间: 2015-11-27 10:33
- @echo off
- for /f "tokens=2 delims= " %%a in ('findstr "20.*-v5i64.exe" "md5-hash.txt"') do set filename=%%a
复制代码
作者: lijinan 时间: 2015-11-27 10:37
回复 2# flyinnet9
非常感谢!
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |