简体   繁体   English

Windows批处理字符串作为字符串的定界符

[英]Windows batch string as delimiter for a string

I have a file containing multiple lines. 我有一个包含多行的文件。 I need only this line : 我只需要这一行:

 Table: DSMAIN_FRANF.DEF02_002_REF_B - Deleted row(s) count: 44

In fact, I need only the number at the end of the line. 实际上,我只需要在行末添加数字。 The length of the line is variable, also the number, but the substring " Deleted row(s) count:" will always be there. 该行的长度是可变的,也是可变的,但是子字符串“ Deleted row(s)count:”将始终存在。

How can I get only what comes after "Deleted row(s) count:" in a line? 如何仅获得一行中“已删除的行数:”之后的内容?

assuming, the syntax of the line is reliable ( ___:_____ Deleted row(s) count: xx ) 假设该行的语法可靠( ___:_____ Deleted row(s) count: xx

for /f "tokens=3 delims=:" %%i in ('find "Deleted row(s) count:" t.txt') do set /a count=%%i
echo %count%

(also assuming, there is only one of those lines; if several, this will give you the last one) (还假设只有这些行之一;如果有几行,这将为您提供最后一行)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM