FINDSTR using variable from text file (Batch,Scripting)
I have a statement, which removes a specific string out of a text file, although how can I define this string f开发者_JAVA技巧rom a text file.
E.g. the text file has one line of text and I efectively want that text to go inbetween "/c:"<HERE>" >>"
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?
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.
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
精彩评论