how to redirect the output of findstr to a variable ?

  • Thread starter Thread starter thinktwice
  • Start date Start date
T

thinktwice

findstr /c:test list.txt //set some variable equals to the output of
findstr, how could i do that?
 
thinktwice said:
findstr /c:test list.txt //set some variable equals to the output of
findstr, how could i do that?

Try this:
@echo off
for /F "delims=" %%a in ('findstr /c:test list.txt') do set var=%%a
 
thanks Pegasus :), it works

=============

I should hope so! Thanks for the feedback.
 
thanks Pegasus :), it works

=============

I should hope so! Thanks for the feedback.

btw, is there any advanced usage of findstr to find among the output
conent of a command execution? i know i could redirect the output of
the command to a temporarily file first then use findstr to search in
that file.
 
thanks Pegasus :), it works

=============

I should hope so! Thanks for the feedback.

btw, is there any advanced usage of findstr to find among the output
conent of a command execution? i know i could redirect the output of
the command to a temporarily file first then use findstr to search in
that file.

=================

In the reply I gave you, you're picking up the
output from findstr.exe without going through
an intermediate temp file.
 
btw, is there any advanced usage of findstr to find among the output
conent of a command execution? i know i could redirect the output of
the command to a temporarily file first then use findstr to search in
that file.

=================

In the reply I gave you, you're picking up the
output from findstr.exe without going through
an intermediate temp file.

I think he wants to pipe a command into FINDSTR and use it to filter -
which of course is one of its prime uses, for example ...

for /F "delims=" %%a in ('dir ^| findstr /c:test') do set var=%%a

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
 
Back
Top