Supposing we have the following code snippet with a text file sample.txt redirected into STDIN:
@echo off
< "sample.txt" (
set /P "ONE="
set /P "TWO="
findstr /R "^"
)
echo %ONE%, %TWO%
...and the content of the related text file sample.txt:
first
second
third
fourth
The output returned on the console is going to be this, which is exactly what I expect (lines first and second are consumed by set /P, hence findstr receives and processes the remaining lines):
third fourth first, second
The same output is achieved when findstr /R "^" is replaced by sort /R.
However, when replacing the findstr command line by find /V "" or by more, the output will be:
first second third fourth first, second
It seems that although set /P already consumed the lines first and second which is proved by the lastly output line, find and also more still receive the entire redirected data.
Why is this, what causes this behaviour? Is there a way to force find or more to receive only the remaining redirected data that has not already been processed by a preceding command?
(The behaviour is the same when redirecting the output data STDOUT to a text file. Also when executing a command line similar to the above batch code in cmd directly, nothing changes.)