tags:

views:

258

answers:

4

I created a batch that will use windows FINDSTR to search for my selective input.

I am trying to log my results of my search term in a text file called results.txt

So I do have something like this so results are kept not overwritten:

>>Results.txt 

I've created the txt file so it'll write to it, this is what I tried and won't work:

findstr "\<%X%\>" *.txt  
echo >>results.txt

That is what I have for trying to log my results of my search term, however nothing happens.

And when I have findstr "\<%X%>" *.txt >>results.txt

It tries to search for >>results.txt and it's not cooperating.

Anyone know what to do?

I'm doing this because FINDSTR will work in the cmd prompt but if I get too many results it cuts off the top, so I want it to write all the results into the results.txt so I can view the whole results with nothing cut off.

Thanks for the help =)

A: 

Try using /c:

findstr /c:"<%X%>" *.txt >> results.txt

Edit: didn't need the ^ escaping here.

jeffamaphone
A: 

Have you tried putting a space in between >> and results.txt There is an example of it here

Arch
The space won't change anything. It's ignored by the parser.
Joey
A: 

The position of the redirection clause shouldn't matter, so I'd give this a shot:

 >>results.txt findstr "\<%X%\>" *.txt

I've also put a \ before the > because I'm assuming you want start and end word markers rather than a literal >. If I'm mistaken, just take it out again.

But I have to mention that, if all you want to do is stop the voluminous output from scrolling off the top of the console, you could just pipe the whole thing through more:

type honkin_big_file | more

will act as a pager so you can view it bit by bit.

paxdiablo
A: 

For your single line example, you have this:

findstr "\<%X%>" *.txt >>results.txt

Did you mean this:

findstr "\<%X%\>" *.txt >>results.txt

The difference being in the first example it is searching for any occurrence of "%X%>" on a beginning word boundary and the second example is searching for "%X%" on a beginning word boundary with an end word boundary (e.g. single word " %X% ").

It works for me.

Robert