I have a statement, which removes a specific string out of a text file, although how can I define this string from a text file.
我有一个语句,它从文本文件中删除特定的字符串,但我如何从文本文件中定义此字符串。
E.g. the text file has one line of text and I efectively want that text to go inbetween "/c:"<HERE>" >>"
例如。文本文件有一行文字,我有意希望文本介于“/ c:”
The statement is below
声明如下
type ignore_tmp.lst | findstr /v /c:"%ignore%p" >> ignore_tmp_.lst
So I think the real question is, if I echoed the text file, maybe using the type command, how could I set the output as a variable?
所以我认为真正的问题是,如果我回应文本文件,可能使用type命令,我怎么能将输出设置为变量?
1 个解决方案
#1
0
The for command can do what you're looking for, both by reading the file itself or by capturing the output of the type or findstr command, like you said.
for命令可以通过读取文件本身或捕获类型或findstr命令的输出来执行您要查找的内容,就像您所说的那样。
C:\>echo test1 > input.txt
C:\>for /f "delims=" %a in (input.txt) do @set input_content=%a
C:\>echo %input_content%
test1
C:\>echo test2 > input.txt
C:\>for /f "delims=" %a in ('type input.txt') do @set input_content=%a
C:\>echo %input_content%
test2
#1
0
The for command can do what you're looking for, both by reading the file itself or by capturing the output of the type or findstr command, like you said.
for命令可以通过读取文件本身或捕获类型或findstr命令的输出来执行您要查找的内容,就像您所说的那样。
C:\>echo test1 > input.txt
C:\>for /f "delims=" %a in (input.txt) do @set input_content=%a
C:\>echo %input_content%
test1
C:\>echo test2 > input.txt
C:\>for /f "delims=" %a in ('type input.txt') do @set input_content=%a
C:\>echo %input_content%
test2