Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
For loop 将批处理文件的输出传递到for循环中_For Loop_Input_Batch File_Output_Readline - Fatal编程技术网

For loop 将批处理文件的输出传递到for循环中

For loop 将批处理文件的输出传递到for循环中,for-loop,input,batch-file,output,readline,For Loop,Input,Batch File,Output,Readline,我试图通过使用管道将进程的输出传递到for循环中 type %1% | findstr /R /V "Test" | for /F "tokens=*" %%i IN ('more') DO @echo %%i 但是我不知道用什么来代替('more'),以便它读取findstr命令的输出。这可能吗?或者我必须将输出保存到一个文件中,然后在一个完全不同的批处理程序中读入该文件吗?请提供帮助。for循环无法从STDIN中读取,因此您需要将要处理其输出的命令放在Paranthesis中: for /

我试图通过使用管道将进程的输出传递到for循环中

type %1% | findstr /R /V "Test" | for /F "tokens=*" %%i IN ('more') DO @echo %%i

但是我不知道用什么来代替('more'),以便它读取findstr命令的输出。这可能吗?或者我必须将输出保存到一个文件中,然后在一个完全不同的批处理程序中读入该文件吗?请提供帮助。

for
循环无法从
STDIN
中读取,因此您需要将要处理其输出的命令放在Paranthesis中:

for /F "tokens=*" %%i IN ('type %1% ^| findstr /R /V "Test"') DO @echo %%i

请注意,管道必须在子shell(
^
)中转义。

%1%
更改为
%1
,或使用
“%~1”
正确处理引号
for /f "delims=" %%a in ('findstr /rv "Test" "%1%" ^| more') do echo %%a