重定向命令输出在批处理脚本的循环 [英] Redirect output of command in for loop of batch script

查看:120
本文介绍了重定向命令输出在批处理脚本的循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

...
for /F %%F in ('dir /B %* 2> nul') do (
...

我正在试图做的,是放弃该命令的错误的输出(环比标准输出输出)。然而,它抱怨:

What I'm attempting to do here is discard the err output of the command (and loop over the stdout output). However, it complains:

2> was unexpected at this time.

这是一些方法来实现这一目标?

Is this some way to achieve this?

推荐答案

在这种情况下,你需要躲避>像这样

in this case you need to escape the > like this

for /F %%F in ('dir /B %* 2^> nul') do (

这篇关于重定向命令输出在批处理脚本的循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆