Saturday, 31 August 2013

Using findstr to output to file only if data is found

Using findstr to output to file only if data is found

I wanted to use findstr to output the results to a file, but only if the
information I am looking for is found.
For instance if I am using this command..
findstr "123456789" input.txt >>results.txt
Then the results.txt file will be a 0KB blank file named results.txt if it
can't find "0123456789".
What I would like is for the results.txt file not to be formed at all if
it can't find "-123456789" in the input.txt file.
Any suggestions?
Thanks in advance.

No comments:

Post a Comment