how to redirect the output of findstr to a variable ?


T

thinktwice

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

Advertisements

P

Pegasus \(MVP\)

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
 
P

Pegasus \(MVP\)

thanks Pegasus :), it works

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

I should hope so! Thanks for the feedback.
 
T

thinktwice

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.
 
Ad

Advertisements

P

Pegasus \(MVP\)

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.
 
Ad

Advertisements

T

Tom Lavedas

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/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top