Findstr question


J

Jon Smith

I need to run a find or findstr command on a dir with text files, and I need
the lines reterned that get matches, but I DON'T want the file names as
well, just the strings from the files. is there anyway to do that? I've
been pulling my hair out on this one.

the output I'm getting from FIND is

****************
FIND "BASEURL" *.url

---------- SLASHDOT.URL
BASEURL=http://slashdot.org/
---------- THE REGISTER USA.URL
BASEURL=http://www.theregus.com/
****************

and on findstr I'm getting

****************
Slashdot.url:BASEURL=http://slashdot.org/
The Register USA.url:BASEURL=http://www.theregus.com/
****************

but what I want is
****************
http://slashdot.org/
http://www.theregus.com/
****************

thanks
 
Ad

Advertisements

P

Phil Robyn [MVP]

Jon said:
I need to run a find or findstr command on a dir with text files, and I need
the lines reterned that get matches, but I DON'T want the file names as
well, just the strings from the files. is there anyway to do that? I've
been pulling my hair out on this one.

the output I'm getting from FIND is

****************
FIND "BASEURL" *.url

---------- SLASHDOT.URL
BASEURL=http://slashdot.org/
---------- THE REGISTER USA.URL
BASEURL=http://www.theregus.com/
****************

and on findstr I'm getting

****************
Slashdot.url:BASEURL=http://slashdot.org/
The Register USA.url:BASEURL=http://www.theregus.com/
****************

but what I want is
****************
http://slashdot.org/
http://www.theregus.com/
****************

thanks
From the CMD prompt:

for /f "tokens=2 delims==" %a in ('findstr "BASEURL" *.url') do @echo %a

In a batch file:

for /f "tokens=2 delims==" %%a in ('findstr "BASEURL" *.url') do echo %%a
 
F

foxidrive

I need to run a find or findstr command on a dir with text files, and I need
the lines reterned that get matches, but I DON'T want the file names as
well, just the strings from the files. is there anyway to do that? I've
been pulling my hair out on this one.

the output I'm getting from FIND is

****************
FIND "BASEURL" *.url

---------- SLASHDOT.URL
BASEURL=http://slashdot.org/
---------- THE REGISTER USA.URL
BASEURL=http://www.theregus.com/
****************
Just to add to Phil's solution, you can use find as a filter.

From the command line

for %a in (*.htm) do find "BASEURL" <%a


double the %'s for a batch file.
np
 
Ad

Advertisements

J

Jon Smith

sorry for another question, but I'm trying to pipe this to a file and I'm
doing

for /f "tokens=2 delims==" %a in ('findstr /s "BASEURL"
"%homepath%/favorites\*.url"') do @echo %a > c:\bookmark.txt

and it's not working but it's echoing fine, is there something elce i need
to put in there?

Thanks
 
M

Matthias Tacke

Jon Smith said:
sorry for another question, but I'm trying to pipe this to a file and I'm
doing

for /f "tokens=2 delims==" %a in ('findstr /s "BASEURL"
"%homepath%/favorites\*.url"') do @echo %a > c:\bookmark.txt

and it's not working but it's echoing fine, is there something elce i need
to put in there?
Hello Jon,

your posting will be better readable if you omit unrelevant parts and
continue at the end.

The single > creates the file anew every time. Delete the file at start
and then append to it with the doubled >> redirection.

HTH
 
Ad

Advertisements

P

Paul R. Sadowski

Jon Smith said:
sorry for another question, but I'm trying to pipe this to a file and I'm
doing

for /f "tokens=2 delims==" %a in ('findstr /s "BASEURL"
"%homepath%/favorites\*.url"') do @echo %a > c:\bookmark.txt
This should work:
for /f "tokens=2 delims==" %a in ('findstr /s "BASEURL"
"%homepath%/favorites\*.url"') do @echo %a >> c:\bookmark.txt

double > (">>") to append entries to the file. With a single > you are
overwriting the file for each new entry so that in the end only the last
entry would appear in the file.
 

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

Similar Threads


Top